Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

weird software problem with iterrupts on PIC16F877A

Status
Not open for further replies.

Build-A-Burger

Full Member level 1
Joined
Oct 27, 2010
Messages
95
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
Wyoming
Activity points
2,101
I've got a program I've been pulling my hair out over the last couple days. I've got 2 interrupts: one uses timer2 to turn some lights on and off on PORTD. The other interrupt is the serial port which has buffers, error-handling, etc. They seem to both work OK. The problem is I'm using a state table in the main loop to call several functions when a certain key is pressed on the serial terminal. (Putty.exe) I can call a function in the other modules (timer.asm and serial.asm) and pass the param in the W register and it works fine. But for some reason, the W register never changes when I call a function from one of the state table functions. I've stepped thru it using the debugger from MPLAB (MPLAB sim only) and looked at the dissassembly code. The state table only modifies the PCL register but checks to see if the PCLATH is needed but I'm not going out of the first 2k code boundary so I could easily take that part of the code out as long as the code executes within the same 2k boundary and the PCL doesn't increment over FF. I've even tried setting a global variable declaring it Global in the other module and extern in the main.asm. I have all the code up on my website at **broken link removed**
The main loop is in testnewstuff.asm
the serial functions and ISR are in testnewstuff_serial.asm
the timer functions and ISR are in testnewstuff_timer.asm
 

Hi,

Thats a lot of code for anyone to go though.

The only thing that stands out to me, is that you have 2 calls within your ISR, both relatively long routines and using lots of Interrupt instructions ?

If you have a Pickit or ICD2 why not try running it via MPLabs hardware debugger.
 

You have written:
goto State1
goto State2
goto State3
goto State4
goto State5
goto State6
goto State7
goto State8

Please check whether you need to replace goto with a "call'.
 
Last edited:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top