Showing posts with label firmware. Show all posts
Showing posts with label firmware. Show all posts

Friday, March 25, 2011

How to calculate PWM Period for PIC24

TUTURIAL FOR PIC24 Microcontroller

Okay.. this 4ns ( nano second / 1 X 10^-9) is really made my day.

It seem the timer make sense when multiply with 4ns.


At first, i tried to calculate Pulse-Width modulation Mode (PWM) for the timer1 of PIC24 but the period time is make no sense as i got 140us.


Coding to set your timer and interrupt :
********************************************************

_T1IP=4; //  set timer1 priority (4=dafault)
TMR1=0; //clear the time
PR1=34; //set the period register
T1CON=0x8020;  //check T1CON register (Prescale set to 1:64)
_T1IF=0; //clear interrupt flag
_T1IE=1;  //enable T1 interrupt source
********************************************************