Re: Help needed with SCI interrupts (HC12)



Hi, and thank you for your quick reply.
I attempted to write in HTML formatting, to indicate some problems,
but I forgot that this is not supported here.
Anyway here is my feedback to your help:

I understand that in order to overcome this I need to implement an
Interrupt function for the SCI1 port.
I've tried this, but my code gets stuck in an infinite loop when the
SCI reading in functions takes place ( SCI1in(); ).

So which exact instructions is it looping on?

I inspected closer my code by adding some Debugging checkpoints, and
my code loops 3-4 times in the SCI1in() function at the " while
(RxFifo_Get(&letter) == 0){ };" loop when SCI1in is manually called.
Then it just crashes or something.


Are there actually characters in the RF fifo?

If you put a breakpoint in the ISR, is it triggering and storing
characters to the FIFO?

I checked and it appears that the ISR is not reached before program
crashes (SCI1In reached). So i guess my mistake is at a lower level,
something to do with my interrupt implimentation mayb.e


One general note: your memory section pragmas look a little
suspicious. You need to be sure that everything that runs as a result
of the interrupt is in the non-banked memory section - both the ISR
routine, and anything it calls . If you don't it will likely work
fine until your program grows to the size where bank switching is
required, at which point it will start failing in very odd ways.

I`m not really sure what to do with this. Any suggestions are more
than welcome


RxFifo_Put(SCI1DRL); // clears RDRF

I'd be tempted to copy SCI1DRL into a volatile temporary variable so I
could see with the debugger that it's actually getting read, and then
call the routine using that.

The 3-4 readings taken before the program crashes show SCI1DRL as 0,
even though I`m transmitting to the board`s SCI1 port.

I googled around a lot the past days to find SCI communication
examples with interrupts to familiarize with. But I didn`t have much
luck with it.
If you have anything in mind please let me know.

Thank you

.


Quantcast