[KEAZN64] Writing in WDOG_CNTL by assembly

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

[KEAZN64] Writing in WDOG_CNTL by assembly

668 Views
mohammedaboelna
Contributor III

Hello,

I am trying to write in register WDOG_CNTL by the following:

1. Saving address of register WDOG_CNTL in register r3

2. Writing needed value "A6" in register r2

3. Storing r2 value inside address of r3

asm ("MOVS r2,#0x40"); /* 40 */
asm ("LSLS r3,r2,#24");
asm ("MOVS r2,#0");
asm ("MOVS r2,#0x05"); /* 05 */
asm ("LSLS r2,r2,#16");
asm ("ADD r3,r2,r3");
asm ("MOVS r2,#0");
asm ("MOVS r2,#0x20"); /* 20 */
asm ("LSLS r2,r2,#8");
asm ("ADD r3,r2,r3");
asm ("MOVS r2,#0");
asm ("MOVS r2,#0x03"); /* 03 */
asm ("ADD r3,r2,r3");
asm ("MOVS r2,#0");

asm("MOVS r2,#0xA6");
asm("STRH r2,[r3]");

At the last assembly line, assembler jumps to "Hard_Fault" exception.

Would you help please ?

0 Kudos
4 Replies

592 Views
mohammedaboelna
Contributor III

Alright

thank you for your support

0 Kudos

592 Views
mohammedaboelna
Contributor III

Hi,

I also tried to read this register through "LDR" instruction instead of "STR" and also it jumps to "Hard_Fault" exception.

Would you have any idea why the program also crashes with "Read" instruction.

0 Kudos

592 Views
jiri_kral
NXP Employee
NXP Employee

This is only one byte - asm("LDRB r2,[r3]"); works fine. 

I'm not sure what you are trying to do, but writting into CTRL and CTRH  is used for WDOG reconfigure. More details you can find in reference manual - KEA64 Sub-Family Reference Manual, Rev. 2, July 2014 - page 218

Jiri 

0 Kudos

592 Views
jiri_kral
NXP Employee
NXP Employee

Hi, 

the CNTL register is read only - that's why your your program crashes. 

Jiri 

0 Kudos