Code Programming Error at 0900
I have a nice little system which uses CanBus to Control 8 LED lights on a bespoke PCB.
I am using Darrel Taylors excellent SPWM_Int routines.
I have run this for several weeks now on a LABx2 board with the necesary to control four lights for test purposes.
This evening I got round to setting up the bespoke PCBs and programmed the working code.
The code ran first time, but, via telltale leds on the pcb I noticed the mapping of some lights was not correct.
A quick look at the schematic showed that B0,B1,D7,D6,D5,D4,C5,C4 are lights 1-8 respectively
The original test config is B0,B1,D4,D5,B4,B5,B6,B7
No problem I thought, just redefine the SPWM_Pin entries in the main program appropriately.
The code compiled and assembled without errors, but when I program, it quickly fails with code error at 0900.
I have changed the code back and get the same error, I then compiled back up versions of both my program and the SPWM include file, same error.
I changed the programmer hardware, same error. I tried to compile to the LAbx2 hardware and got the same error , but at 0300...
I checked all the configuration settings against 'program, Read' and the configurations are correct. I can reprogram after Read without error. Of course this is just reloading the original code back to the device.
SO....why does a new compile of 'backup' unadulterated code not program, but read back code does?
Why did it compile the first time, but not subsequently?
Clearly missing something...but what ?
Using Mpasm5.03 and PBP 2.6 Pic 18f4580
9PM brainfade may be at play here. Perhaps a fresh look in the morning.
Any wisdom most welcome.
PS
Quick question for Darrel,
I notice the last line in SPWM_Int.bas is OverSPWM:
There is no code after this and no Return ... appreciate this is an include file, so, is this a neat way to branch out of the include back to the main program? I see the sub is called from within the include....
Re: Code Programming Error at 0900
It sounds like the chip may not be getting erased before programming.
If you are using an melabs programmer, in meprog go to Options > More Options > Set Options to Defaults.
The OverSPWM label is so the include can jump over all of it's code.
Otherwise execution would fall into a subroutine without being called from a gosub.
All include files should jump over their own subroutines.
Re: Code Programming Error at 0900
You nailed it. Programming as expected now. Sincere thanks for your support.
I have been using this kit for about six years now and never experienced this. However MEProg does occasionally uncheck 'configuration' in 'Options , More Options , Program' . I quickly recognise the signs now and recheck it, but, anyone else experienced this? Is there a fix or update ?
Re: Code Programming Error at 0900