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.

weird pic code problem

Status
Not open for further replies.

Fletcher

New Member
I cant be bothered commenting it all, but this block of code is meant to 3 print lines of text on a 20x4 hd4470 lcd. the dispmain program clears a counter, sets the cursor position and then calls each routine which prints a line. The 3 line printing routines are exactly the same as each other exept they call a different lookup table and have different labels. The problem i have is when the dispmain program has only the code without the asterisks it works perfectly, however when the other code is entered the pic goes crazy and crashes over and over. can anyone see a problem with it?


Code:
DISPMAIN
CALL CLRDISP
CLRF COUNT1
MOVLW 0X80
CALL CMD
CALL LN1
CLRF COUNT1
MOVLW 0XC0
CALL CMD
CALL LN2
CLRF COUNT1*
MOVLW 0X94*
CALL CMD*
CALL LN4*
RETURN

LN1 MOVF COUNT1,W
CALL SCR1
MOVWF TEMP1
SUBLW 0X26
SKPNZ
GOTO LNEND1
MOVF TEMP1,W
CALL SENDDATA
INCF COUNT1,F
GOTO LN1
LNEND1 RETURN 

LN2 MOVF COUNT1,W
CALL SCR3
MOVWF TEMP1
SUBLW 0X26
SKPNZ
GOTO LNEND2
MOVF TEMP1,W
CALL SENDDATA
INCF COUNT1,F
GOTO LN2
LNEND2 RETURN

LN4 MOVF COUNT1,W
CALL SCR6
MOVWF TEMP1
SUBLW 0X26
SKPNZ
GOTO LNEND4
MOVF TEMP1,W
CALL SENDDATA
INCF COUNT1,F
GOTO LN4
LNEND4 RETURN

SCR1
ADDWF PCL,F
DT "Speed:&"

SCR3
ADDWF PCL,F
DT "Temp: &"

SCR6
ADDWF PCL,F
DT "Mode sets AUTO/MAN&"
 
I would suggest your tables may be crossing a 256 byte boundary, this causes the program counter to jump to the wrong location. It's easiest to move all tables to near the beginning of program memory, and jump over them at the start of the program - or you can move them to the start of a 256 byte boundary in higher memory, and set the PCL bits before calling it.
 
Thanks for the help, i thought it might be something like that. ill have a play with it.

SKPNZ is a pseudo-op ,it gets replaced with BTFSC STATUS,2 when it assembles.
 
Fletcher said:
Thanks for the help, i thought it might be something like that. ill have a play with it.

SKPNZ is a pseudo-op ,it gets replaced with BTFSC STATUS,2 when it assembles.

oh .. :)
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top