Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F93727460
pwm.c
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Dec 1, 00:38
Size
1 KB
Mime Type
text/x-c
Expires
Tue, Dec 3, 00:38 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
22623360
Attached To
R6619 Oncilla Motordriver Firmware
pwm.c
View Options
#include "pwm.h"
#include <gpio.h>
void pwm_init(pwm_t * pwm, pwm_device_t device){
switch(device){
case PWM_1_1 :
pwm->DC = &(P1DC1);
pwm->TPER = &(P1TPER);
pwm->TCON = &(P1TCON);
pwm->CON1 = &(PWM1CON1);
pwm->pin = 0;
break;
case PWM_1_2 :
pwm->DC = &(P1DC2);
pwm->TPER = &(P1TPER);
pwm->TCON = &(P1TCON);
pwm->CON1 = &(PWM1CON1);
pwm->pin = 1;
break;
case PWM_1_3 :
pwm->DC = &(P1DC3);
pwm->TPER = &(P1TPER);
pwm->TCON = &(P1TCON);
pwm->CON1 = &(PWM1CON1);
pwm->pin = 2;
break;
case PWM_2_1 :
pwm->DC = &(P2DC1);
pwm->TPER = &(P2TPER);
pwm->TCON = &(P2TCON);
pwm->CON1 = &(PWM2CON1);
pwm->pin = 0;
break;
default :
pwm->DC = 0;
pwm->TCON = 0;
pwm->CON1 = 0;
pwm->TPER = 0;
pwm->pin = 0;
break;
}
//enable the channel globally
atomic_or(pwm->TCON , 1 << 15);
//initialize the pin as an output !!!
atomic_or(pwm->CON1, ( 1 << (pwm->pin + 4)) | (1 << (pwm->pin + 8)));
}
Event Timeline
Log In to Comment