Carlos Pinheiro

Serial Interrupt with the MC9S12NE64

Discussion created by Carlos Pinheiro on Apr 18, 2006
Latest reply on Apr 24, 2006 by Carlos Pinheiro
Hi Everybody,
 
I´m having a terrible nightmare when programing the serial with interrupt. Here is the code. I´ll be very gratefull.
 
#include <hidef.h>      /* common defines and macros */
#include <MC9S12NE64.h>     /* derivative information */
unsigned char c;
unsigned char d, aux;
#pragma LINK_INFO DERIVATIVE "1"
void main(void) {
 SCI0BDH = 0x00;
 SCI0BDL = 0x28;
 SCI0CR1 = 0x00;
 SCI0CR2 = 0x2C;
 d=1;
 EnableInterrupts;
 while(1){
    if (d){
       aux = SCI0SR1;
       SCI0DRL = 'f';
       while((SCI0SR1 & 0x80) == 0);
       d=0;
  }
 }
}
 
#pragma CODE_SEG NON_BANKED
interrupt 20 void trataRecepcao(void) {
   aux = SCI0SR1;
   c = SCI0DRL;
   d = 1;
   aux = SCI0SR1;
   SCI0DRL = 'f';
   while((SCI0SR1 & 0x80) == 0);
}

Outcomes