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.

How to set program counter to illegal address while code is running?

Status
Not open for further replies.

jani12

Advanced Member level 4
Full Member level 1
Joined
Oct 30, 2014
Messages
108
Helped
0
Reputation
0
Reaction score
1
Trophy points
1,298
Activity points
2,536
How to set program counter to illegal address while code is running ?

I'm trying to create illegal instruction reset.

I'm programming Infineon TC29x Aurix Tricore Microcontroller based embedded system in 'C' language.

I need to set program counter to illegal address, i.e. 0x00FF FFFC. Can this be done with assembly language instructions?
If yes, please instrument assembly language instruction that would set program counter to 0x00FF FFFC while code is running
 

Re: How to set program counter to illegal address while code is running ?

I tried to look at the documentation for the uP, but they won't give it out freely. Not a way to win new customers, in my opinion.

Regardless, my best solution if there's no way to directly load the PC would be maybe call a subroutine, which puts the program counter on the stack. Then have your subroutine modify that location in the stack so when you return from the subroutine, voila, bad PC!
 

    V

    Points: 2
    Helpful Answer Positive Rating
Re: How to set program counter to illegal address while code is running ?

I think you cannot write into a program counter register. It is read only register. If there is mistake in the code cpu will automatically generates illegal instruction. If you want to write data into a particular address define a pointer to that address and try writing some data into that address and cpu will generate illegal address interrupt.
 

    V

    Points: 2
    Helpful Answer Positive Rating
Re: How to set program counter to illegal address while code is running ?

Hi,

Writing into a PC register is the same as performing an unconditional absolute jump.
But maybe the compiler/assembler detects an error when you jump to an illegal address.

The modifed_stack_and_return method should work either way.

Klaus
 

Re: How to set program counter to illegal address while code is running ?

I didn't try it, but it should work. Try to use pointer to a function like this:

Code C - [expand]
1
2
int (*func)(void) = 0x00FFFFFC;
    func();

 

Re: How to set program counter to illegal address while code is running ?

Small fix: int (*func)(void) = (void*)0x00FFFFFC;
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top