How to set PC using usbdmscript.exe ?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to set PC using usbdmscript.exe ?

Jump to solution
2,963 Views
Mindblaster
Contributor III

HI, i want to set program counter (PC register) to a given value.

I guess this can be done using the rreg/wreg commands, but i don't know the register-number to enter.

 

0 Kudos
1 Solution
2,950 Views
Mindblaster
Contributor III

For some reason i do not understand, i found out that PC is register number "3", so

wreg 3 0x8000

did the job

% wreg 3 0x8000
:wReg r=0x3(PC)<-0x00008000

View solution in original post

0 Kudos
4 Replies
2,951 Views
Mindblaster
Contributor III

For some reason i do not understand, i found out that PC is register number "3", so

wreg 3 0x8000

did the job

% wreg 3 0x8000
:wReg r=0x3(PC)<-0x00008000
0 Kudos
2,924 Views
pgo
Senior Contributor V

UsbdmScript uses internal register numbers defined in:

https://github.com/podonoghue/usbdm-eclipse-makefiles-build/blob/master/Shared/src/USBDM_API.h 

There are also some special commands such as wpc.

wc <value> - Write control register
wpc <value> - Write to PC
wreg <regNo><value> - Write core register
wdreg <regNo><value> - Write debug register
wcreg <regNo><value> - Write control register

Registers vary by target type

You can use the following to give names to registers (HCS12 example):

proc hcs12regs { } {

   set PC 3 ;# PC reg
   set D 4 ;# D reg
   set X 5 ;# X reg
   set Y 6 ;# Y reg
   set SP 7 ;# SP reg
   set CCR 0x80 ;# CCR reg - redirected to USBDM_ReadDReg()

   return
}

You can then add the above to usbdm_rc.tcl. Then commands will be more readable:

hcs12regs ;# once only or add to usbdm_rc.tcl if this is the only target you use.
...

wreg $Y 100

bye

0 Kudos
2,908 Views
Mindblaster
Contributor III

Veeery cool! This is an extremely good tool, i used it a lot. Also many thanks for the new, advanced GUI and the option to also read back EEPROM pages, save/load setup and more address-fields, that was really missing

Maybe you could also add a setting to access paged RAM?

I also wonder why the "regs" command of usbdmscript does not tell CCR flags, this would be very helpfull for branch commands an such.

0 Kudos
2,899 Views
pgo
Senior Contributor V

Hi,

It would probably be sensible to add CCR to regs for HCS12.  The only reason it wasn't is that the CCR is accessed differently to the other registers in the BDM interface.

You can read the CCR by either:

rreg 0x80 ;# it reports unknown register but it gives the correct value (same as below command).
rdreg 0xff06 ;# this is a special debug command to access the temporary register containing the CCR value.

 

0 Kudos