LPC1769: pwm cannot run at the same time

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

LPC1769: pwm cannot run at the same time

970 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Wilbur He on Tue Feb 24 04:59:26 MST 2015
I have configured pwm1.2 and 1.3 to control 2 servo motors, however, only pwm1.3 can run properly, pwm1.2 cannot work unless i disable the pwm1.3 in init_PWM, why? I will be very appreciated if anyone can help me solve this problem.



Labels (1)
0 Kudos
16 Replies

943 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by SirLelox on Sat Jun 06 07:24:37 MST 2015
yep this is the solution for me too!  :D
0 Kudos

943 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Wilbur He on Tue Feb 24 05:57:16 MST 2015
I change the "=" in init_pwm to "|=", now it's working!! thanks! i will read that tutorial carefully later, thanks!!!
0 Kudos

943 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Wilbur He on Tue Feb 24 05:56:36 MST 2015
I change the "=" in init_pwm to "|=", now it's working!! thanks!
0 Kudos

943 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Wilbur He on Tue Feb 24 05:54:12 MST 2015
I am really really very appreated for your help, i try to check it one more time
0 Kudos

943 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by starblue on Tue Feb 24 05:45:52 MST 2015

Quote: Wilbur He
why they can't be set at the same time?, they are different bits)


You have to set them at the same time, in a single assignment. You do it by two assignments, so the bits for the first part are overwritten in the second assignment.
0 Kudos

943 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Wilbur He on Tue Feb 24 05:45:02 MST 2015
Sorry I quickly read that tutorial. The problem might be the register can't be accessed by bits?Thank you for your patience!! If I delete one pwm configuration in init_pwm, I can just control one servo. where should put another pwm configuration?
0 Kudos

943 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Tue Feb 24 05:33:49 MST 2015

Quote: Wilbur He
I think this is trying to set both p2.1 and p2.2's function to be pwm1.2 and 1.3,



Yes  :)



Quote: Wilbur He
(but I know it's wrong now, why they can't be set at the same time?, they are different bits)



Did you miss the lesson 'bitwise operators' last week  :quest:

That's basic stuff  :O

See: http://www.cprogramming.com/tutorial/bitwise_operators.html

0 Kudos

943 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Wilbur He on Tue Feb 24 05:27:28 MST 2015
PINSEL4 Pin name Function when 00 Function when 01 Function when 10 Function when 11
 
               1:0 P2.0   GPIO Port 2.0       PWM1.1                    TXD1                 Reserved        
               3:2 P2.1   GPIO Port 2.1       PWM1.2                    RXD1                 Reserved         
               5:4 P2.2   GPIO Port 2.2        PWM1.3                    CTS1                 Reserved

I think this is trying to set both p2.1 and p2.2's function to be pwm1.2 and 1.3, So I thought the result is d. (but I know it's wrong now, why they can't be set at the same time?, they are different bits)
0 Kudos

943 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Tue Feb 24 05:25:43 MST 2015
Come on, I'm waiting...
0 Kudos

943 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Tue Feb 24 05:17:58 MST 2015
LPC_PINCON->PINSEL4 = 1 << 2; //P2.1 works as PWM1.2 output.pin43,MR2
LPC_PINCON->PINSEL4 = 1 << 4; //P2.2 works as PWM1.3 output.pin44,MR3


What do you think, which bits are set in (32bit) register PINSEL4 now  :quest:

a: bit2

b: bit4

c: bit6

d: bit2 and bit4

e: no bits are set
0 Kudos

943 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Wilbur He on Tue Feb 24 05:13:37 MST 2015
I am sorry that I still don't quite understand, Which line should I delete, I set two registers here.... Crying  Crying (you are so nice, i saw you replied many posts in this forum)
0 Kudos

943 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Wilbur He on Tue Feb 24 05:11:19 MST 2015
I am sorry that I still don't quite understand, Which line should I delete, I set two registers here.... :((  :((  (you are so nice, i saw you replied many posts in this forum)
0 Kudos

943 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Tue Feb 24 05:06:42 MST 2015

Quote: Wilbur He

...
LPC_PINCON->PINSEL4 = 1 << 2; //P2.1 works as PWM1.2 output.pin43,MR2
LPC_PINCON->PINSEL4 = 1 << 4; //P2.2 works as PWM1.3 output.pin44,MR3
LPC_PINCON->PINMODE4 = 1 << 5; //enable P2.2,MR3 neither pull up nor pull down.
LPC_PINCON->PINMODE4 = 1 << 3; //enable P2.1,MR2 neither pull up nor pull down.
...



Of course that's nonsense, you are setting your registers twice, deleting the last setting  ;-)
0 Kudos

943 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Wilbur He on Tue Feb 24 05:06:25 MST 2015
I am so Sorry that I  just learnt LPC programming last week, do you know the problem? can you tell me? Thank you very much!!!
0 Kudos

943 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Tue Feb 24 05:04:04 MST 2015

Quote: Wilbur He
Can anyone help me? I am waiting online now



Don't wait, read a C book...
0 Kudos

943 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Wilbur He on Tue Feb 24 05:02:51 MST 2015
Can anyone help me? I am waiting online now
0 Kudos