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.

Problem with program as the PC jumps to different part of code when adding offset

Status
Not open for further replies.

qmriso

Member level 5
Joined
Nov 30, 2006
Messages
80
Helped
2
Reputation
4
Reaction score
1
Trophy points
1,288
Activity points
1,879
ok, im new to programming pics. im writing code to run a bipolar stepping motor in microstep mode by outputting a pwm signal to each coil. the pic i'm using all i have is a simple 8 line table with my pwm duty cycles. im using the simple "computed goto" function. now my problem is, when i add my offset to the pcl, the pc jumps to a totally different part of my code. im sure im overlooking something, but i'm just too new at this to know what it is.
thanks for reading.
qmriso
 

Re: Problems...

Maybe it is the Program Bank switching thing.
Some PIC microcontroller requires you to switch bank,
before you can jump to the correct PC location.

Which PIC microcontroller are you using.
Maybe if you provide some example of your code,
it will be helpful to find out to real cause.


www.siongboon.com
 

Re: Problems...

Hi,
when u r adding offset to PCL, the content of PCLATH is automatically loaded to the higher byte of PC. So before adding offset to PCL load PCLATH with higher byte of your offset.

For Example: If your u want to go to address 0x1000, and if ur current address(PC value) is 0x10 then ur offset is 0x00(Take lower byte of address 0x1000)-0x10=0xF0. First load PCLATH with high byte of 0x1000, that is 0x10. then perform adding offset 0xF0 with PCL. PC will automatically be transfered to 0x1000.

Thanks.
 

Re: Problems...

hmm....thanks for ure help..
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top