[Avrora] USART0, UDRE interrupt

Ben L. Titzer titzer at cs.ucla.edu
Thu Sep 22 10:49:10 PDT 2005


On Sep 21, 2005, at 4:25 PM, Richard Barrington wrote:

> Hi there,
>
> I've got an AVR application that I'm running through Avrora, and  
> seem to be having issues with serial comms. I made a platform with  
> a couple of LEDs on it, and can toggle one of them on USART0, RX  
> when the device receives data via a serial forwarder. I'm using  
> bidilink and mincom to talk to Avrora.
>
> My problem is that the USART0, UDRE interrupt never fires. Data (if  
> any is waiting) is supposed to be sent back to the terminal when  
> the buffer is empty and this interrupt is triggered. In the example  
> below, sending 'Man' should reply with 'Hello>'. I guess this means  
> that the buffer is never empty, but this application works just  
> fine on the actual hardware... so I'm wondering what I'm doing  
> wrong with Avrora. Or do I need to handle this part manually, and  
> check the buffer and fire the interrupt in the platform (or  
> monitor) code? Or better yet, is there an example somewhere of  
> working interrupt-driven usart comms?
>

There may be a problem with the USART implementation; it should  
handle the posting of interrupts on its own, and your platform class  
need not implement this behavior on its own. Which microcontroller  
model does your platform use?

I usually test against code that I think does not rely on the  
interrupts to determine when to send the next byte, so I think I may  
not have exercised this case. I have a lot on my hands right now, but  
if you want to take a look at the relevant code, you will find it in  
avrora.sim.mcu.USART.

It may also be a bug with the interrupt mapping numbers (i.e.  
simulator posts the wrong interrupt number which is masked out by  
your program). You can check this with a probe or watch through the  
State.getInterruptTable() method, which has methods to check which  
interrupts are posted, enabled, pending, etc.

Hope this helps,
-B
> Thanks,
> Richard.
>
> Here's some output to illustrate:
>
> [richard at testbox bin]$ java -Xms64M -Xmx256M avrora.Main - 
> seconds=30.0 -single -verbose=atmel.usart0 -platform=genboard - 
> timeout=3120 -monitors=serial,interrupts -action=simulate - 
> input=objdump vems.obj
> Avrora [Beta 1.6.0] - (c) 2003-2005 UCLA Compilers Group
> This simulator and analysis tool is provided with absolutely no  
> warranty,
> either expressed or implied. It is provided to you with the hope  
> that it be
> useful for evaluation of and experimentation with microcontroller  
> and sensor
> network programs. For more information about the license that this  
> software is
> provided to you under, specify the "license" option.
> Loading vems.obj...[OK: 12.262 seconds]
> =={ Simulation events } 
> =======================================================
> Node          Time   Event
> ---------------------------------------------------------------------- 
> --------
> Waiting for serial connection on port 2390...connected to / 
> 127.0.0.1:39147
>   0         16342  LCD_EN: on
>   0         17873  USART0: period set to 161
>   0      22878282  USART0: Received frame 0x4D [01001101] (77) 'M'  
> 0 -96 16
>   0      22878324  CAN_CS: on
>   0      23969512  USART0: Received frame 0x61 [01100001] (97) 'a'  
> 0 -96 16
>   0      23969555  CAN_CS: off
>   0      24820838  USART0: Received frame 0x6E [01101110] (110) 'n'  
> 0 -96 16
>   0      24820880  CAN_CS: on
>   0     101939978  USART0: Received frame 0x62 [01100010] (98) 'b'  
> 0 -96 16
>   0     101940020  CAN_CS: off
>   0     102329822  USART0: Received frame 0x79 [01111001] (121) 'y'  
> 0 -96 16
>   0     102329863  CAN_CS: on
>   0     102633034  USART0: Received frame 0x65 [01100101] (101) 'e'  
> 0 -96 16
>   0     102633076  CAN_CS: off
> ====================================================================== 
> ========
> Simulated time: 480000000 cycles
> Time for simulation: 117.584 seconds
> Total throughput: 4.082188 mhz
> =={ Monitors for node 0 } 
> =====================================================
> =={ Interrupt monitor results } 
> ===============================================
> Num  Name        Invocations  Separation  Latency     Wakeup
> ---------------------------------------------------------------------- 
> --------
>  1  RESET                 0
>  2  INT0                  0
>  3  INT1                  0
>  4  INT2                  0
>  5  INT3                  0
>  6  INT4                  0
>  7  INT5                  0
>  8  INT6                  0
>  9  INT7                  0
> 10  TIMER2 COMP           0
> 11  TIMER2 OVF            0
> 12  TIMER1 CAPT           0
> 13  TIMER1 COMPA          0
> 14  TIMER1 COMPB          0
> 15  TIMER1 OVF            0
> 16  TIMER0 COMP           0
> 17  TIMER0 OVF            0
> 18  SPI, STC              0
> 19  USART0, RX            6  1.595095E7  0.5         4.0
> 20  USART0, UDRE          0
> 21  USART0, TX            0
> 22  ADC                   0
> 23  EE READY              0
> 24  ANALOG COMP           0
> 25  TIMER1 COMPC          0
> 26  TIMER3 CAPT           0
> 27  TIMER3 COMPA          0
> 28  TIMER3 COMPB          0
> 29  TIMER3 COMPC          0
> 30  TIMER3 OVF            0
> 31  USART1, RX            0
> 32  USART1, UDRE          0
> 33  USART1, TX            0
> 34  TWI                   0
> 35  SPM READY             0
>
> _______________________________________________
> Avrora mailing list
> Avrora at lists.ucla.edu
> http://lists.ucla.edu/cgi-bin/mailman/listinfo/avrora
>

========================================================
One machine can do the work of fifty ordinary men. No machine can do  
the work of one extraordinary man.
--Elbert Hubbard

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ucla.edu/pipermail/avrora/attachments/20050922/4de0beb5/attachment-0001.html


More information about the Avrora mailing list