Flollowing an extract of the code I use for SCI.
When I send datas, via a buffer :
SCI1DRL = data to send...
SCI1CR2 |= 0x88; // enable interrupt on Xmit buffer empty
//***********************************************************************
void SCI1_Init (Word baudrate, Byte sysclk)
{ SCI1BDH = // your value for speed
SCI1BDL = // your value for speed
SCI1CR1 = 0x00;
SCI1CR2 = 0x2c; // enable xmit/receive, int on receive only
}
//************************************************************************
#pragma interrupt_handler ISR_Sci1
void ISR_Sci1 (void)
{ unsigned char sci_status;
sci_status = SCI1SR1;
// Interruption on receive buffer full
if (sci_status & 0x28) // RDRF 0x20 : Receive data register full
{ // Your code for reception
}
// Interruption on xmit buffer empty
if (sci_status & 0x80) // TDRE : 0x80 ; Transmit Data Register
Empty
{ // Your code for transmission
if (/* your condition for xmit not finished */)
{ SCI1DRL = .../...
}
else // nothing else to xmit
{ SCI1CR2 &= 0x3f; // disable xmit interrupt
}
}
}
Best regards.
Joel
-----Message d'origine-----
De :
68HC12@... [mailto:
68HC12@...] De la part de
ben_smida_hamdi
Envoyé : jeudi 9 avril 2009 13:02
À :
68HC12@...
Objet : [68HC12] trouble with S12XS SCI controller
i'm developing an uart driver based on interrupts.
i've realized that when executing the ISr software failed to reset TDRE
Flag.i made sure tha i've followed all steps listed in the datasheet to do
so which are:
1-reading the SCI Status Register.
2-Writing to the SCI Data Low register.
but the ISR Continue to go in Loop.
i wish tha anyone could help me figure this out.
------------------------------------
Yahoo! Groups Links