Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

I just might be close to nuts.

Status
Not open for further replies.

Ian Rogers

User Extraordinaire
Forum Supporter
Most Helpful Member
Or!! even there..

I have spent the last week or so on an issue.. I currently use an IDE from Proteus and it serves me well. and my recent project requires an LED bargraph.. I have 4 spare pins and set up a 10 LED charlieplexed bargraph.. It works very well and the LED's are bright enough and I have the refresh on timer0 set to 2mS a piece which gets me 50hz and all's good.

The second part of the project is serial RS485 component input ... Both running on the same interrupt The serial worked but the bargraph failed... So I set up High / Low priority... Still the same.. When debugging I noticed that in the interrupt routine, TRISB ( high ) wasn't being set... I have a 11 char array to hold the tristate of each LED and a second to reverse the bits to LIGHT the correct LED.. After many hours I decided to port the whole shabang to MPLABX whereas it worked first time as expected... Ye gods I thought.. The text editor in the Proteus IDE is screwing everything up... Went back to Proteus... Still in op.

Phoned the guy's at Proteus who immediately jumped into action.. They couldn't reproduce the error...

So.... MPLABX compiles the file and links the file and the file is good.. Proteus doesn't ( Same code ).

The guy at Proteus just got back to me and said he couldn't find the issue, but he did notice that a string buffer I was using was one byte too short. I checked said buffer and it had no influence on the result, but it made me think..

In the serial interrupt I have another string buffer that was 10 characters too small.. In the interrupt I clear the buffer in a 0 ~ 29 loop... The buffer is only 20 chars... Guess where Proteus links the buffer..... MPLABX links it slightly different and didn't affect my TRISB table... But as Proteus lists alphabetically... Bugger..
 
In the interrupt I clear the buffer in a 0 ~ 29 loop... The buffer is only 20 chars...
I learnt many years ago that the use of sizeof greatly reduces these kinds of bugs. Which, as you know, are VERY difficult to find. As Nigel said, well found.
I also try to use if(5==var) to stop the if(var=5) type bug.

Note, I give good advise but don't always follow it.:D

Mike.
 
I think the main point is the days in between... You kind of convince yourself that the issue is elsewhere..

That took 5 days of my life and added "more" grey hairs... I'm glad I found it, but it's kids stuff.

Classic copy and paste error.

I share this so others can look back and say.... "LOL I did that"
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top