Pic still freezing

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
Desdewit
Posts: 130
Joined: Sat Feb 26, 2011 4:26 am
Location: South Africa
Has thanked: 25 times
Been thanked: 11 times
Contact:

Pic still freezing

Post by Desdewit »

Hi Guys

Please see if you can help this is getting very annoying :evil: :evil:
I cannot get my pic to stop freezing after receiving rs232 data for a while. Could this be a flowcode or pic error?
It seems that the only way to get it running again is by doing a reset. (And that I do not want to do.)
The bytes are received in strings of 84 bytes every 500ms, after every 14 bytes I must do a checksum and make sure byte 8 of each 14 is 0 then 1 then 2, 3, 4 and 5.
Sometimes it will run for a long time before freezing.

I'm using a Pic18f252 with hardware & software Usart.
19660800Hz Crystal
V3 Development board HP488
Maxim232

Received data sample:

001 000 010 129 255 001 001 000 000 000 000 000 000 140
001 000 010 129 000 001 001 001 000 000 000 077 188 151
001 000 010 129 001 001 001 002 000 000 000 019 017 180
001 000 010 129 002 001 001 003 000 000 000 019 136 045
001 000 010 129 003 001 001 004 000 000 000 019 178 089
001 000 010 129 004 001 001 005 000 000 000 019 136 049

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: Pic still freezing

Post by kersing »

Making your program available so we can test might help...
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

Desdewit
Posts: 130
Joined: Sat Feb 26, 2011 4:26 am
Location: South Africa
Has thanked: 25 times
Been thanked: 11 times
Contact:

Re: Pic still freezing

Post by Desdewit »

Hi Kersing

I've attatched the file.
Attachments
RS232 Temp.fcf
(18.73 KiB) Downloaded 262 times

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: Pic still freezing

Post by Enamul »

Hi,
It should work now..RXINT can't work without peripheral interrupt enable. If you use RXINT you don't need to wait so long for data, 1 time out should be fine but for safety I put 5. Let me know how you are getting..
Attachments
RS232 Temp.fcf
(19.08 KiB) Downloaded 261 times
Enamul
University of Nottingham
enamul4mm@gmail.com

Desdewit
Posts: 130
Joined: Sat Feb 26, 2011 4:26 am
Location: South Africa
Has thanked: 25 times
Been thanked: 11 times
Contact:

Re: Pic still freezing

Post by Desdewit »

Thanks Enamul

So far the pic does not freeze even after an error.
Do you know why the pic freezes if the peripheral interrupt are not enabled?
Do you know if there is a specific reason why flowcode does not enable the peripheral interrupt when RXInt are chosen?

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: Pic still freezing

Post by Enamul »

It was a bug in Flowcode and Ben posted a fix for all FCDs but seems that you didn't notice that and lots of other user like you didn't notice that.
Enamul
University of Nottingham
enamul4mm@gmail.com

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: Pic still freezing

Post by Benj »

Hello,

Is the device still freezing for you? It sounded from what you posted like the problem had been resolved.

My guess is that the freezing is caused by a stack overflow (too many jumps away from main) in which case enabling the software stack should solve this problem. Search the forums for software stack and you should find the solution to allow you to do this.

Another cause could be that code is being executed and then the interrupt kicks in and tries to call the same piece of code which can lead to corrupted variable values etc when you return to the original routine. To get around this try setting a flag in the interrupt macro and then servicing the flag somewhere in your main routine. Circular buffers may be an option if you need interrupt data to accumilate until you are free to process it.

Desdewit
Posts: 130
Joined: Sat Feb 26, 2011 4:26 am
Location: South Africa
Has thanked: 25 times
Been thanked: 11 times
Contact:

Re: Pic still freezing

Post by Desdewit »

Hi Ben

Sorry about the confusion, the program is in two parts with one (Hardware TX & RX) & one (Software TX & Rx). At first the two programs were running separately with problems that Enamul help solved, but when I combined the two programs a whole new set of errors & warning messages started again

Serious Warning: Possible sw stack corruption, function 'FC_CAL_UART_Delay_1' called by more than one asynchronous thread (main/Task, interrupt, interrupt low)
Serious Warning: Possible sw stack corruption, function 'delay_us' called by more than one asynchronous thread (main/Task, interrupt, interrupt low)

I've tried solving the problem by adding -swcs 6 2 to the Parameters like suggested in the forums but then receive "Error: Failed to open:6" ". Error: Failed to open:2."

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: Pic still freezing

Post by Benj »

Hello,

Are you sure you put the additional parameters into the linker params text field and not the compiler one.

Desdewit
Posts: 130
Joined: Sat Feb 26, 2011 4:26 am
Location: South Africa
Has thanked: 25 times
Been thanked: 11 times
Contact:

Re: Pic still freezing

Post by Desdewit »

Hi Benj

This is the line from my Linker/Assembler Parameters:

-ld "C:\Program Files (x86)\Flowcode\v5\Tools\BoostC\lib" libc.pic16.lib rand.pic16.lib float.pic16.lib "%f.obj" -t PIC%p -d "%d" -p "%f"-swcs 6 2

Please confirm that this is correct?

If I change my receive routine like this the warning messages are gone and so far the program keeps running, but I get more receiving errors.
Are there anything you can see wrong with this part of my routine that might cause the receive errors?
I’ve tested the program with 4Mhz & 19.6608Mhz Crystal @ 9600 baud.
I’m using RB0Int with software usart for this part of the routine
Attachments
Temp.fcf
(31.18 KiB) Downloaded 240 times

Desdewit
Posts: 130
Joined: Sat Feb 26, 2011 4:26 am
Location: South Africa
Has thanked: 25 times
Been thanked: 11 times
Contact:

Re: Pic still freezing

Post by Desdewit »

Hi

If I use hardware and software RS232 on a 18f252 & disable “RXint” while using “RB0int” to receive and then later disable “RB0int” and enable “RXint” and so on, will it cause any type of problems :?:

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: Pic still freezing

Post by Benj »

Hello,
-ld "C:\Program Files (x86)\Flowcode\v5\Tools\BoostC\lib" libc.pic16.lib rand.pic16.lib float.pic16.lib "%f.obj" -t PIC%p -d "%d" -p "%f"-swcs 6 2
This looks to be correct to me.
If I use hardware and software RS232 on a 18f252 & disable “RXint” while using “RB0int” to receive and then later disable “RB0int” and enable “RXint” and so on, will it cause any type of problems :?:
Cant see any issues with doing this as long as you don't mind missing data if both UARTS receive at exactly the same time. The hardware UART should buffer up to 2 bytes anyway so as long as you service the software UART as the data is coming in then you should be ok.

Post Reply