Boostc C compiler error when RS232 in TMR0 interuption

Forum for problems or queries regarding Flowcode Comms Components. Eg LIN, I2C, SPI, RS232, CAN, IrDA etc

Moderators: Benj, Mods

Post Reply
ROMANO1
Posts: 13
Joined: Tue Apr 22, 2008 9:15 am
Contact:

Boostc C compiler error when RS232 in TMR0 interuption

Post by ROMANO1 »

Hello
It is not my lucky week with FLowcode!
Voila, when I try to put a macro RS232
in a program under interrupt TMR0
I receive an error compiler C.See the picture



The stack can be lost!
It is true the PICs have few bytes of stack
How then?

Thank you
Attachments
error.jpg
error.jpg (19.68 KiB) Viewed 3897 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Boostc C compiler error when RS232 in TMR0 interuption

Post by Benj »

Hello

Your program is compiling and not receiving an error just a serious warning. The warning is referring to code that is called in your main routine and in an interrupt routine. If the program runs ok then there is probably nothing to worry about. If the program does not run ok then the best thing to do is to try to move as much as you can out of the interrupt routine and back into the main routine. This is good coding practise anyway as when you are in the interrupt routine you are blocking that interrupt from firing again if it needs to.

ROMANO1
Posts: 13
Joined: Tue Apr 22, 2008 9:15 am
Contact:

Re: Boostc C compiler error when RS232 in TMR0 interuption

Post by ROMANO1 »

I know,it's a warning!
But I'm only four levels of sub program in the worst case.
The compiler tells me 8!
How can you embed sub programs? 8 or less?
Or can we have the significance of the error messages
compiler Boostc.Il none in the boostc.pdf.J got searched on the site http://forum.sourceboost.com/ but I have not found.
Thank you

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Boostc C compiler error when RS232 in TMR0 interuption

Post by Benj »

Hello

Yes you can have up to 8 layers using the hardware stack and up to 255 using the boostc software stack.

The warning message is saying that your main code has 4 layers and your interrupt code has 5 layers resulting in a possible 9 layer stack.

You are also getting a second warning saying your code is being called by two asynchronous routines. An example of why this is bad practise and therefore why the warning message is appearing is below.

RS232 example.

The main program is sending a value through the RS232. The byte value is loaded into the RS232 outgoing buffer and just before it is sent an interrupt occurrs.

Inside the interrupt a second byte is sent over the RS232. This byte actually gets sent.

When returning to the main we finish sending the first byte but instead of the data we expect to send we are again transmitting the data from inside the interrupt.

A worse case suituation is that the main is running some non re-entrant code and if the interrupt happens to run the same piece of code then it has the possibility of crashing/damaging the chip. This is unlikley in a microcontroller context but it is possible.

A better method is to do as little as possible from inside the interrupt eg set a flag variable. Then in the main program we can poll the variable and if it changes state then we can do something.

If you need to turn on the boostc software stack then you can do so by adding "-swcs s1" to the linker options.

Hope this helps.

Post Reply