Keil Logo

C166: HOW TO GET 16-BIT ADDRESSES INTO THE PEC REGISTERS?


Information in this article applies to:

  • C166 Version 3.12
  • C166 Version 4.01

SYMPTOMS

Help. I'm using C166 and I'm having trouble getting real 16-bit addresses into the PEC source and destination registers. How do I do that?

CAUSE

The library function _sof_ must be used to get the real 16-bit address for segment 0 addresses. This function combines the segment (DPP register) and offset to get a real 16-bit address.

RESOLUTION

The following example program should help. It transmits a string out the serial port using PEC channel 0.

#include "reg167.h"
#include "intrins.h"

const char string1 [] = "0123456789\n"; // must be located in segment 0!


// This function initializes PEC Channel 0  to move the data from
// STRING1 to the serial transmit buffer.

void serial_PEC0_setup (void)
{
  PECC0 = 0x0500                      // Move Bytes, Inc Src Ptr
         | ((sizeof (string1) / sizeof (string1 [0])) - 1);
  SRCP0 = _sof_ (string1);            // Source is STRING1
  DSTP0 = 0x00FEB0;                   // Destination is the serial output
}


// The Serial TX interrupt just resets PEC 0 and transfers another
// copy of STRING 1.

void serial_TX_irq (void) interrupt S0TINT = 42
{
  serial_PEC0_setup ();
}


void serial_baudrate (unsigned int baud)
{
  S0BG = (20000000UL / (32UL * (unsigned long) baud));
}


// The setup routine for the serial port also initialized the PEC 0
// transfer and sets a TX interrupt request

void serial_setup (unsigned int baud)
{
  serial_baudrate (baud);

  DP3 |=  0x0400;     // Set TXD for output
  DP3 &= ~0x0800;     // Set RXD for input
  P3  |=  0x0400;     // Set TXD high
  S0CON = 0x8011;
  S0TIC = 0x00F8;     // Serial TX IRQ = Level 14, Priority 0 (PEC 0)

  serial_PEC0_setup ();

  IEN = 1;            // Enable interrupts
}


void main (void)
{
  serial_setup (19200);

  while (1)
  {
  }
}

MORE INFORMATION

  • Refer to _sof_ in the C166 User's Guide.

SEE ALSO

FORUM THREADS

The following Discussion Forum threads may provide information related to this topic.

Last Reviewed: Monday, March 5, 2007


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.