Peripheral register not set with correct values

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

Peripheral register not set with correct values

929 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by 256Doofus on Thu Jun 09 06:06:14 MST 2011
When setting the LPC_TMR32B1->[SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]PWMC [SIZE=3][COLOR=#000000]to 0x11 it will only be sett to 0x1.[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE]

Some suggestion?



[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void
[/COLOR][/SIZE][/COLOR][/SIZE][/B][LEFT][SIZE=2][B]Timer_Setup[/B]([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2])[/SIZE]
[LEFT][SIZE=2]{[/SIZE][/LEFT]
[/LEFT]

[INDENT]
[LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]volatile[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint32_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] temp = 0;[/SIZE]
[LEFT][SIZE=2]LPC_SYSCON->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]SYSAHBCLKCTRL[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] |= (1<<10);[/SIZE][/LEFT]
 
[LEFT][SIZE=2]LPC_IOCON->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]JTAG_TDO_PIO1_1[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] &= ~0x07;[/SIZE]
[SIZE=2]LPC_IOCON->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]JTAG_TDO_PIO1_1[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] |= 0x03; [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// Timer1_32 MAT0[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#3f7f5f]
[/COLOR][/SIZE][SIZE=2]LPC_IOCON->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]JTAG_nTRST_PIO1_2[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] &= ~0x07;[/SIZE][/LEFT]


[LEFT][SIZE=2]LPC_IOCON->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]JTAG_nTRST_PIO1_2[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] |= 0x03; [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// Timer1_32 MAT1[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#3f7f5f][/LEFT]
[/COLOR][/SIZE]
[LEFT][SIZE=2]LPC_TMR32B1->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]PR[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = 0;[/SIZE]
[SIZE=2]LPC_TMR32B1->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]MR0[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = 0xffffffff;[/SIZE]
[SIZE=2]LPC_TMR32B1->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]MR1[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = 0xffffffff;[/SIZE]
[SIZE=2]LPC_TMR32B1->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]MR3[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = TIME_INTERVAL;[/SIZE]
[SIZE=2]LPC_TMR32B1->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]MCR[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = (1 << 10); [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]//Reset on MR3: the TC will be reset if MR3 matches it.[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#3f7f5f][/LEFT]
[/COLOR][/SIZE]
[LEFT][SIZE=2]LPC_TMR32B1->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]PWMC[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = 0x11; [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]//PWM enable on CT32B1_MAT0 and CT32B1_MAT1[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#3f7f5f]
[/COLOR][/SIZE][SIZE=2]temp = LPC_TMR32B1->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]PWMC[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];[/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]//LPC_TMR32B1->EMR = 0x10100000; //PWM enable on CT32B1_MAT0 and CT32B1_MAT1[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#3f7f5f][/LEFT]

[LEFT][/COLOR][/SIZE][SIZE=2]LPC_TMR32B1->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]TCR[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = 1; [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]//Enable Timers[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#3f7f5f][/LEFT]
[/LEFT]

[/COLOR][/SIZE]
[/INDENT][SIZE=2]}[/SIZE]


[LEFT][SIZE=2][COLOR=#000080][SIZE=2][COLOR=#000080]LPC_TMR32B1->PWMC = 0x11; //PWM enable on CT32B1_MAT0 and CT32B1_MAT1[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2]0x00000ec6 <Timer_Setup+254>: movw r3, #32768 ; 0x8000[/SIZE]
[SIZE=2]0x00000eca <Timer_Setup+258>: movt r3, #16385 ; 0x4001[/SIZE]
[SIZE=2]0x00000ece <Timer_Setup+262>: mov.w r2, #17[/SIZE]
[SIZE=2]0x00000ed2 <Timer_Setup+266>: str r2, [r3, #116] ; 0x74[/SIZE]
[SIZE=2][COLOR=#000080][SIZE=2][COLOR=#000080]temp = LPC_TMR32B1->PWMC;[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2]0x00000ed4 <Timer_Setup+268>: movw r3, #32768 ; 0x8000[/SIZE]
[SIZE=2]0x00000ed8 <Timer_Setup+272>: movt r3, #16385 ; 0x4001[/SIZE]
[SIZE=2]0x00000edc <Timer_Setup+276>: ldr r3, [r3, #116] ; 0x74[/SIZE][/LEFT]
[SIZE=2]0x00000ede <Timer_Setup+278>: str r3, [r7, #4][/SIZE]
0 Kudos
Reply
5 Replies

918 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by 256Doofus on Thu Jun 09 06:37:15 MST 2011
Se that 0b did come with the 4.3 gcc

"
Integer constants written in binary are now supported as a GCC extension. They consist of a prefix 0b or 0B, followed by a sequence of 0 and 1 digits.
"
0 Kudos
Reply

918 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Thu Jun 09 06:33:30 MST 2011
You can also write your values binary, but I don't want to see things like

value32bit = 0b11001100100101010001001000100111; :eek:

in my code. Perhaps readable for 8-bit values, but not for 32-bit :)
0 Kudos
Reply

918 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by 256Doofus on Thu Jun 09 06:21:05 MST 2011
LPC1343

But of cource.... I was thinking 0b11....... :o

But why not 0b in C ?
0 Kudos
Reply

918 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by igorsk on Thu Jun 09 06:20:43 MST 2011
Zero, I think you should send a check to NXP for all the support you're doing here :)
0 Kudos
Reply

918 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Thu Jun 09 06:17:09 MST 2011
Are we talking about LPC1114?

0x11 is not valid :eek:

If you want to set MAT0 and MAT1 the right value is 0x03 (bit0 + bit1) :)
0 Kudos
Reply