SEI and RXC

Go To Last Post
5 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Dear forum members,

I have encountered a problem with the RX complete interrupt.

When I use interrupt system call to handle RX complete interrupts, my STK300 board hangs. When I run the code in simulation mode in AVR studio is appears as if the interrupt system calls is the problem.

Studying the assembler output from gcc for the interrupt system call shows that a SEI is plced first in the system call. According to the mega103 manual I must clear the RXC flag before I can enable the global interrupt again. If not the system will just to the interrupt vector again.

When I patched a nop instead of the SEI in the hex output the software ran just fine, both on target and in simulation. ( I use a sei() call at the end of all my interrupt sutines. )

I am missing something here ? Can I use any flags during compilation or linking to disable the insertion of SEI in the interrupt system call ? Is this a desired behaviour ? Have anyone seen this problem ?

/ mika

admin's test signature
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have this problem too... I can't make the RXC interrupt work.
(see thread in the general forum for more info.)

Is there anyone who has been able to make the RXC interrupt work using GCC?

I use the 8535.

admin's test signature
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello,
I use avr-gcc and 8515. RXC complete interrupt works fine (9600 baud). I have the STK500 board and wrote a simple terminal programm in delphi. This program sends 4 Byte Commands to the 8515. I use all serial interrupts without any problem.
Try the gcctest4 (or 3?? I can't remember). It puts rec. bytes on portd- leds and works fine.

Hanns Tappeiner

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Dear Hanns,

thank you for your response.

Maybe I have misunderstood the difference between the keywords SIGNAL and INTERRUPT. I use INTERRUPT i my code.

"The interrupt routine with the keyword SIGNAL is executed with disabled interrupts." and more "The interrupt routine with the keyword INTERRUPT is executed with enabled interrupts." You can find this in the Getting Started Notes written by Harald Leitner on page 33.

I will investigate the assembler output for the call with keyword SIGNAL. You are right about the gcctest4. But I do not understand the text in Harald Leitner document when I study the code in gcctest4. Keyword INTERRUPT should have been used here according to Harald Leitner document. Maybe I am missing something here ?

Can you please explain the difference between keywords SIGNAL and INTERRUPT and why keyword SIGNAL and not INTERRUPT is used in gcctest4. Interrupts are enabled in gcctest4:

"outp((1<<RXCIE)|(1<<TXCIE)|(1<<RXEN)|(1<<TXEN),UCR); " and
"sei(); /* enable interrupts */"

/ mika

admin's test signature
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi, Mika,

as far is I now the only difference is: SIGNAL puts a cli() at the beginning of the your interrupt-routine, so another interrupt cannot get active while your routine is executed.

INTERRUPT does not insert these command. The effect is that an active interrupt-service-routine (ISR) can be interrupted by another interrupt of higher priority. The priority is fixed by the order of the interrupt-vectors, so INT0 is of higher priority than INT1 or TIMER1 CAPT.

In both cases (Signal and Interrupt), the end of your routine will be a RETI-Instruction which will return to the previous function and --!!--> set the global interrupt-flag again <--!!--. As an effect, calling cli() from inside a signal/interrupt will not be effective after the ISR has been left. If you want to disable all interrupts in your program in certain situations, you have to call cli() from a normal function outside of the ISR.

In your example, the expicit call of sei() is necessary only one time during initialisation of your program, otherwise no interrupt could ever become active.

You will find that SIGNAL is used in almost all examples, because it is easier to have the interrupts handled one after another. With INTERRUPT, you have to take care of what will happen if different interrupts occur at nearly the same time. You could get timing differences, access-conflicts to resources like timers, global variables etc.

But also with SIGNAL, you don't have to be afraid that you miss an interrupt. If the ISR cannot be executed because of locked interrupts (SIGNAL) or because a ISR of higher priority is just being executed (INTERRUPT), the interrupt stays pending until interrupts are enabled again. If several interrupts are pending, the priority again takes effect.

Kind regards - Helmut

admin's test signature