simulavr-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Simulavr-devel] UART Interrupt and Timer problem


From: Klaus Rudolph
Subject: Re: [Simulavr-devel] UART Interrupt and Timer problem
Date: Tue, 10 May 2005 10:32:36 +0200 (MEST)

Hi Jakob,

I hope we are talking about simulavrxx :-)

I tried to reproduce your problem:
first I have to remove the global.h file which I not have.
next was setting F_CPU to 16000000.
After that I tested the application with:
simulavr -datmega128 -f uartproblem -t /dev/stdout 

I saw that the vector for TXC was called a lot and the irq handler
was executed as expected. After raising the irq the irq was cleared 
before calling the irq handler itself which is correct.
The volatile variable was also written correct and no other problems
comes up.

There are a lot of "IrqFlagCleared Vec:4" which seems a bit misterious,
but this is correct because the TXD-Pin is on the same port like the
external IRQ pins
for the device so the check runs also for the complete port and
the mode for the ext irq is set to 0 for each pin and this means
if the pin is 0 the irq must be cleared. That is also done and
traced out. This is not nice and I maybe change the message so that 
only the first "irqClear" is monitored.

If the problem still exist please ask again! Maybe I have done something
different.

Thanks
   Klaus

> Hi,
> 
> I have a problem with using the UART1 on a atmega128 simulation. My
> application that is running fine on hardware seems to cause some
> troubles in the simulator. The actual program was using the
> procyon-avrlib for higher-level access to the uart. Using it caused
> the simulation to stall after transmitting a byte. Changing the
> baudrate changed it, but would still lead to unwanted behaviour.
> I have created a small program that sets up the uart and sends bytes
> with a delay to test for the behaviour. The debug output reveals that
> it seems to be trapped in the IRQ. After the first byte has been
> transmitted it would repeat the debug output from the irq handler.
> Could there be a problem in the simulator with clearing the TXC
> interrupt after it has been thrown?
> On the same note, on my receiving end I am using a modified serialrx
> class to listen to the UART1. Even with the irq problem I am having,
> the first byte is being transmitted. However, for this to work I have
> to set up the baudrate in the serialrx class to 2*19200 for it to
> work.
> My F_CPU is 16000000
> I set up the simulation with
> dev1->SetClockFreq(1000/16);
> 
> anything I am missing? Help would be greatly appreciated. 
> btw.: Great code! Very easy to read.
> 
> //----- Include Files
> ---------------------------------------------------------
> #include <avr/io.h>
> #include <avr/signal.h>
> #include <avr/interrupt.h>
> 
> #include "global.h"
> 
> #define UART1_BAUD  19200
> 
> //----- Begin Code
> ------------------------------------------------------------
> 
> volatile u08   uartReadyTx;
> 
> int main(void)
> {
>    // set LED pins for output
>    DDRA = _BV(DDA2) | _BV(DDA4);      
> 
>    // set BAUD rate for UART1
>    UBRR1L = ((F_CPU+(UART1_BAUD * 8L))/(UART1_BAUD * 16L)-1);
>    UBRR1H = 0;
> 
>    // init UART1 and enable TXC interupt
>    UCSR1B = BV(TXEN)|BV(TXCIE); 
> 
>    uartReadyTx = 0;
> 
>    // enable all interupts
>    sei();
> 
>    while(1) {
>       // wait for uart to be ready
>       while( uartReadyTx );
> 
>       // delay
>       int m = 33000;
>       while( m-- );
> 
>       // send byte through uart
>       UDR1 = 0x55;
>       // set uart not ready
>       uartReadyTx = 1;
> 
>       // debug
>       sbi( PORTA, PA2);
>       cbi( PORTA, PA2);               
>    }
> 
>    return 0;
> }
> 
> INTERRUPT(SIG_UART1_TRANS)      
> {
>    // debug
>    sbi( PORTA, PA4);
>    cbi( PORTA, PA4);          
> 
>    // set uart ready
>    uartReadyTx = 0;   
> }
> 
> 
> _______________________________________________
> Simulavr-devel mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/simulavr-devel
> 

-- 
+++ Lassen Sie Ihren Gedanken freien Lauf... z.B. per FreeSMS +++
GMX bietet bis zu 100 FreeSMS/Monat: http://www.gmx.net/de/go/mail




reply via email to

[Prev in Thread] Current Thread [Next in Thread]