PDA

View Full Version : PBP3 with PIC18F87K22 and variables



MisterT
- 21st February 2012, 22:11
I have just spent 10 hours or so struggling with the following problem:-

HARDWARE
EasyPIC PRO board from Mikroelektronika fitted with PIC18F87K22. Modified to use PICkit3 programmer, as it programs much faster than the Mikroelektronika mikroprog.

SOFTWARE
PBP3 with MicroCode Studio, using MPLAB X. All downloaded a few days ago, so up to date.

I can compile code and download it and it runs, so the setup is basically sound. I have put a simple loop with 200mS delay flashing an LED on RA4 so I can tell the program runs.
My problem is with variable names and what happens when I change them.

zhfk_81 and zhk82 are pre-defined BYTES
The following code section runs ok. LEDs on PORTD count up as expected.

zfhk_81 = zfhk_81 + 1
zhk82 = zfhk_81
portd = zhk82

However the following code section does not run, although RA4 still flashes, showing that the loop is going round.
(the declaration for zfhk_81 has been changed to a word)

zfhk_81 = zfhk_81 + 1
zhk82 = zfhk_81.BYTE0
portd = zhk82

Also changing the name of variable zfhk_81 (a BYTE) to something like charger_demand or reg81 stops the originally working version. Although the LED on RA4 still flashes. The PIC watchdog has been turned off in the config, so I am sure the PIC is not crashing and resetting.

All of the above works fine with PBP 2.6 and MPLAB.

Does anybody have any ideas???

Many thanks

MisterT

MisterT
- 3rd March 2012, 11:09
Problem solved.
I have reinstalled PBP 3 and set the assembler to MPASM instead of MPASM X.
Everything works ok now.

MisterT