-
1. Re: Not seeing TI_0 interrupt flag when sending serial data mode 0
ananda_26 Feb 25, 2011 6:49 AM (in response to ben.udall)Benote,
Please let us know the modification you've done to call ISR_USART0() when the interrupt occurs.
The only 2 interrupt sources of usart0 are TI_0 and RI_0 if both are not set then it most probably has to do with the way the isr is called. In codes that i've written i usually poll TI and RI, haven't really tried using in ISR. If possible please attach your code here so that we can figure what is going wrong.
Regards,
Anand
-
2. Re: Not seeing TI_0 interrupt flag when sending serial data mode 0
ben.udall Mar 2, 2011 7:29 PM (in response to ben.udall)Hi Anand,
Thank you for your reply. ISR_UART0() is in a seperate c file (isr.c) due to the #pragma NOIV directive in periph.c. I was assuming the compiler would generate the appropriate code automatically so the function would be called on interrupt 4 (0x0023) based on the function's definition:
void ISR_USART0(void) interrupt 4
Within TD_Init() I then set bit 4 (ES0) in IE to enable the serial port 0 interrupts.
The interrupt does seem to be working in some fashion, given that LED2 turns on, however in further testing, I've discovered that the device stops responsing over USB once I try sending data serially. If I disable the serial interrupt, the issue goes away and the device responds normally after sending serial data.
I've attached the project code. The EZ-USB Interface in CyConsole can be used to send a Vendor Request 0x40 to trigger the sending of the byte over serial.
Thanks,
Ben
-
3. Re: Not seeing TI_0 interrupt flag when sending serial data mode 0
ananda_26 Mar 3, 2011 12:07 AM (in response to ben.udall)Hi Ben,
I don't see the attachment.
TI and RI are bit-addressable so one thing you might want to try is read them directly than using the & operator on SCON0 to get the values.Regards,
Anand
-
4. Re: Not seeing TI_0 interrupt flag when sending serial data mode 0
ben.udall Mar 3, 2011 9:48 AM (in response to ben.udall)Whoops, figures I would miss that. It should be attached here. I will try the bit addressable method and see what happens there.
-Ben
-
5. Re: Not seeing TI_0 interrupt flag when sending serial data mode 0
ben.udall Mar 3, 2011 10:02 AM (in response to ben.udall)Hmm, file attachement didn't work a second time. I'm this time with IE in case there's an odd issue using Firefox.
-
comtest.zip 38.8 K
-
-
6. Re: Not seeing TI_0 interrupt flag when sending serial data mode 0
ben.udall Mar 3, 2011 10:14 AM (in response to ben.udall)Crazy, the bit addressable method seems to have been the key. Changing ISR_UART0() to the following produces the results I would expect, LED2 and LED4 turn on and the device continues to respond to USB commands.
void ISR_USART0(void) interrupt 4
{
unsigned char temp;temp = LED2ON;
if (RI != 0)
{
temp = LED3ON;
RI = 0;
}if (TI != 0)
{
temp = LED4ON;
TI = 0;
}
}Is there any explanation for this kind of behaviour? I was under the impression that the bit-addressable SFRs were there almost as a convience/save a few cycles kind of thing but not required. In any case, it seems to be working now. Thanks for your help Anand!
-Ben
-
7. Re: Not seeing TI_0 interrupt flag when sending serial data mode 0
ananda_26 Mar 3, 2011 12:08 PM (in response to ben.udall)Ben,
We'll have to look at what the compiler was trying to do to understand why the other approach didn't work.
Not sure if it reads the value from the sfr and ANDs 0x01 or it ANDs 0x01 to that register directly. The fact that USB does not respond threw all kind of red flags. Happy to know that your code works.
Regards,
Anand