Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++

programatically set the PC

Altera_Forum
Honored Contributor II
1,173 Views

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, 

John
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
467 Views

Hi John, 

 

You can do something like this: 

 

#define SOME_ADDR 0x .... void whatever () {   void (*foo)(void) = (void (*)(void)) SOME_ADDR;    ...    foo(); /* call SOME_ADDR */ } 

 

Regards, 

--Scott
0 Kudos
Altera_Forum
Honored Contributor II
467 Views

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!
0 Kudos
Altera_Forum
Honored Contributor II
467 Views

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.
0 Kudos
Reply