• 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.

Question!!

Status
Not open for further replies.

IVANHVG

New Member
:?

Hi i´m new here, I´m from Bogotá, Colombia and I have a question.
i don´t know wether the issue i´m having programming a PIC 16f877 is very simple or not, however I do know it´s driving me crazy.


Well, I have programmed this PIC (just assembly) to interface with an LCD and also some pushbuttons. Right now everything works, however when i try to add even a little instruction, the microcontroller goes crazy.

I used the degug option in MPLAB and effectively there is problem, when the microcontroller goes into a certain Call subroutine it suddenly jumps to another call routine that is right before that one. I have checked all my labels and no problem there, But it is when I add even the slighttest code in some other area that this problem occurs. I have also checked the pages numbers for both program and data memory. For program memory I´m below the 2000 words so I should be on page 0.
Also the pages for the data memory should be okay since the code works fine, up until i try to add any instruction.

I have also checked with the debugger the stack making sure that I don´t call more than 8 subroutines at the same time (I believe the stack is eight levels deep from the data sheet).

I would greatly appreciate if someone could help me out here. I have to say that this is the first time I´m programming with a PIC and I don´t know many things. On the other hand if the information provided here is not enough I would send code or explain more the problem.

Again thanks, if someone has a suggestion as to why this might be happening.

Ivan
 

IVANHVG

New Member
Code

As I mentioned, whenever i try to put code anywhere, this program stops working. Also to acces RAM memory locations at 20h to 7Fh on page 0, I have to be on page1 which i think is wrong, but then again i´m probably missing something.

The code is in zip format
 

Attachments

TheAnimus

New Member
Hey i don't have the emulator on this computer, so i'm not gonna even try to read all that code (looks like a hudge project) only remind you that the PC is only 8bit, so u need to set PCALH
(the higher bits)
From what your saying this sounds like the problem.
 

TheAnimus

New Member
just thought to glance over your code by eye.

Clearlcd is called accross a boundary, and i can't see PCLATH been set properly!!
 

IVANHVG

New Member
Hi animus!!!
Thanks for looking over that huge code. You know i really don´t know wha t you mean by
"Clearlcd is called accross a boundary, and i can't see PCLATH been set properly!¨"
But i do know that that might be were the problem is because, suddenly that is the subroutine that keeps coming up. In other words the LCD keeps clearing up after I add any code. I did discover some errors in page numbers that fixed some other bugs but the Cleralcd problem is still there.

Could you explain to me very quick what is a boundary and how do I set PCLATH properly???
At the moment i´m reading more of the data sheet, so that i´m trying to understand about the PC. The routines that use for the text strings fo the LCD, are from the internet and i don´t even know how they work

Again thanks for you help, which I greatly appreciate.
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top