Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Help needed. To generate PWM on a freescale microcontroller

Status
Not open for further replies.

pic_newbee

Newbie level 3
Joined
Aug 26, 2010
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
India
Activity points
1,296
Hi all

Am using Freescale Micro controller MC9S08SH8. Iam trying to create a PWM using this controller. Though I have carefully set all the registers related to PWM, Am still unable to generate PWM on this.

The main task was to create a edge aligned PWM on all channels of each PWM.
also am using internal oscillator it has.

Can any one give me some example C Codes for the same or try correcting my code

Tools am using: Codewarrior suite with P&E Programmer
Controller: MC9S08SH8 20pin


Any kind of help is greatly appreciated

Thanks!


Code:
#include <hidef.h> /* for EnableInterrupts macro */
#include "derivative.h" /* include peripheral declarations */

void main(void) {

  EnableInterrupts; /* enable interrupts */

     //TIMER1 CH0 n CH1
     
     TPM1SC=0b01001000;
     TPM1C0SC=0b00101000;  //Edge aligned pwm with high true pulses 
     TPM1C1SC=0b00101000; 
     TPM1MOD=400;
     TPM1C0V=400;
     TPM1C1V=400;
     
     //TIMER2 CH0 n CH1 
  
     TPM2SC=0b01001000;
     TPM2C1SC=0b00100100; //Edge aligned pwm with low true pulses 
     TPM2C0SC=0b00100100;
     TPM2MOD=400;
     TPM2C1V=400;
     TPM2C0V=400;

while(1)
{
TPM1C0V=300;
TPM1C1V=300;
TPM2C1V=300;
TPM2C0V=300;
}  
 }
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top