hantto
Member
Hello!
I've been programing a 877A, and it throws me errors (like printing the LCD full with only the fist letter from a table). It seems like it doesn't like to modify the program counter. I noticed that if I moved tables (yes I have taken into account the 256 word boundary) or other subroutines around a little in the code, they would magically start working, or stop working.
I see no error in my code, and I have been looking at for some time now. Then I discovered the read-modify-write way the PIC uses. I looked through my code and inserted delays in places where there might have been some issues. That didn't help. I have used most of the routines in this code before, so it's confirmed that they work.
Then I wrote this little program to test a routine on another page:
And it didn't work, I looked at the example in the datasheet. This is so simple it should work?
So I'm reaching the conclusion that the PIC must be defect.
Yes, I ran it off a regulated 5v supply (7805) with adequate decoupling (a 10µF and a 100nF).
Or am I missing something? (again)
I've been programing a 877A, and it throws me errors (like printing the LCD full with only the fist letter from a table). It seems like it doesn't like to modify the program counter. I noticed that if I moved tables (yes I have taken into account the 256 word boundary) or other subroutines around a little in the code, they would magically start working, or stop working.
I see no error in my code, and I have been looking at for some time now. Then I discovered the read-modify-write way the PIC uses. I looked through my code and inserted delays in places where there might have been some issues. That didn't help. I have used most of the routines in this code before, so it's confirmed that they work.
Then I wrote this little program to test a routine on another page:
Code:
LIST P=16F877A, F=INHX8M
include "P16F877A.inc"
__CONFIG 0x2942
ERRORLEVEL 0, -302 ;Suppress bank selection messages
ERRORLEVEL 0, -207 ;Suppress "label found after column 1"
#define Sup5V PortA, 4 ;5v supply controll
#define ButBL PortC, 1 ;Port C1 = Button backlight
#define LCDBL PortC, 2 ;Port C2 = LCD backlight
cblock 0x20
delay ;Delay
delaya ;Delay
delayb ;Delay
endc
org 0x00 ;Program memory Page 0
clrf Status ;For bootloader compatibility
clrf PCLath
goto Init
Init clrf PortA
clrf PortC
bsf Status, rp0 ;Bank 1
movlw b'11101011' ;PortA
movwf TrisA
movlw b'10000001' ;PortC
movwf TrisC
bcf Status, rp0 ;Bank 0
Main bsf LCDBL ;LCD backlight ON
call Delay250
bsf pclath, 4 ;Select page 2
bcf pclath, 3
call Flash_Buttons
bcf LCDBL ;LCD backlight OFF
call Delay250
bsf pclath, 4 ;Select page 2
bcf pclath, 3
call Flash_Buttons
goto Main
Delay250 movlw d'250' ;delay 250mS
movwf delay
d1 movlw 0xE7
movwf delaya
movlw 0x04
movwf delayb
Delay_0 decfsz delaya, f
goto $+2
decfsz delayb, f
goto Delay_0
decfsz delay ,f
goto d1
return
org 0x1000 ;Program memory Page 2
Flash_Buttons btfss LCDBL ;test if LCD backlight on
bcf ButBL
btfsc LCDBL
bsf ButBL
return
end
And it didn't work, I looked at the example in the datasheet. This is so simple it should work?
So I'm reaching the conclusion that the PIC must be defect.
Yes, I ran it off a regulated 5v supply (7805) with adequate decoupling (a 10µF and a 100nF).
Or am I missing something? (again)