Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Thread Tools Display Modes
Old 13th October 2004, 12:59 PM   (permalink)
Default weird pic code problem

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&"
Fletcher is offline   Reply With Quote
Old 13th October 2004, 01:15 PM   (permalink)
Default

Quote:
I cant be bothered commenting it all,
Well guess what, I for one, can't be bothered reading it all.
:twisted:
JohnBrown is offline   Reply With Quote
Old 13th October 2004, 01:31 PM   (permalink)
Default

oh well, screw it. ill rewrite the whole thing and see if if starts working.
Fletcher is offline   Reply With Quote
Old 13th October 2004, 01:35 PM   (permalink)
Default

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.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline   Reply With Quote
Old 13th October 2004, 01:40 PM   (permalink)
Default

SKPNZ ..
i've never seen this command .. must be a newer pic..?
williB is offline   Reply With Quote
Old 13th October 2004, 01:55 PM   (permalink)
Default

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 is offline   Reply With Quote
Old 13th October 2004, 02:09 PM   (permalink)
Default

Yep that fixed it, just had to move the tables higher up.
Fletcher is offline   Reply With Quote
Old 13th October 2004, 02:10 PM   (permalink)
Default

Quote:
Originally Posted by Fletcher
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 ..
williB is offline   Reply With Quote
Old 13th October 2004, 02:12 PM   (permalink)
Default

Quote:
Originally Posted by Fletcher
Yep that fixed it, just had to move the tables higher up.
how large are the tables..?
williB is offline   Reply With Quote
Old 13th October 2004, 02:39 PM   (permalink)
Default

Quote:
Originally Posted by Fletcher
SKPNZ is a pseudo-op ,it gets replaced with BTFSC STATUS,2 when it assembles.
Yes, there's also a large number of others listed in the MPASM helpfile table B.11!.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes




All times are GMT. The time now is 11:55 AM.


Electronic Circuits  |  Electronics Wiki
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.