ARM Technical Support Knowledge Articles

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

Applies to: C166 C Compiler

Answer


Information in this article applies to:


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
"; // 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

SEE ALSO

Article last edited on: 2007-03-05 08:03:40

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential