Forum Discussion
Altera_Forum
Honored Contributor
21 years agoprogramatically set the PC
Hello,
I have a system with a 1s10 and Nios II with an exception address pointing to an internal Boot Monitor ROM. I have built (in SOPC builder) into the Boot ROM a .c file which turns on some lights and things. When that is done running - I want it to set the program counter to run out of either RAM or Flash. Anybody know how I can direct the PC to a new address (in c code compiled by SOPC builder into a ROM)??? thanks, John3 Replies
- Altera_Forum
Honored Contributor
Hi John,
You can do something like this:
Regards, --Scott#define SOME_ADDR 0x .... void whatever () { void (*foo)(void) = (void (*)(void)) SOME_ADDR; ... foo(); /* call SOME_ADDR */ } - Altera_Forum
Honored Contributor
Thanks for the tip. I'll try it this morning sometime and I'll let you know...
Of course it will be hard for me to tell if it works because I'm having a problem running out of external flash. When I program external flash with my program (via the Flash Programmer in the N2 IDE which reports success) and set the reset vector to external flash in SOPC builder - nothing happens on reset or power up, the program doesn't run. Yet I can run from external RAM no problem. Any ideas on that one? thanks again! - Altera_Forum
Honored Contributor
I presume you are setting the reset vector before generating your software. If you have modified your hardware more recently than your software then this may be your problem.
You can debug your boot loader (with the 1.1 kit) by setting up a launch configuration for the project and selecting the "reset target and attach to program at reset vector" option. You should then be able to step into your code. You will need a processor with hardware breakpoints if you want to insert breakpoints or step over anything.