Peter Argue

Troublewith SCI transmit on S12C32

Discussion created by Peter Argue on Feb 8, 2008
Latest reply on Feb 10, 2008 by Peter Argue
Hi,

I am trying to write a simple program to output data on the sci port of a MC9S12C32. My problem is that when I write a value to the SCIDRL register, the value is not written and 0x00 is written instead. However when I write to SCIDRH it works fine.

Below is the code i am trying to run.

Code:
#include <hidef.h>      /* common defines and macros */
#include <mc9s12c32.h>     /* derivative information */
#pragma LINK_INFO DERIVATIVE "mc9s12c32"

#define BAUD_RATE_DIVIDER 130 // 9600  Baud


void sendData(void);
void initialize(void);
void interrupt 20 sciHandler(void);

int sendCount;
int done;

void main(void) {

  initialize();
  EnableInterrupts;

  sendData();

  for(;;)
    if(done) { break; }}void initialize(void) { // initalize the system  done = 0;  sendCount = 0;    // clear flags  SCISR1;  SCIDRL = 1;    // initialize SCI module    SCIBDH = 0x00;  SCIBDL = BAUD_RATE_DIVIDER;                                      SCICR1 = 0x00;  SCICR2 = 0xC8;// turn on tx and related interrupts}void sendData(void) {  SCIDRH = 0xFF; // this works and writes 0x40 to the register (T8)  SCIDRL = 0x55; // this writes 0x00 to the register    // I've also tried this and got the same results  //asm {  //  movb  $FF,SCIDRL;  //}     if(sendCount++ == 100) { done = 1; }}void interrupt 20 sciHandler(void) {  if(SCISR1_TC){// Transmit Complete    //sendData();  }  if(SCISR1_TDRE){// Transmit Data Register Empty     if(done == 0){      sendData();    }  }}

 

Any thoughts on what I am doing wrong?


Outcomes