Apply PWM signal to PIN of a Microcontroller

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

Apply PWM signal to PIN of a Microcontroller

644 Views
sheetanshkaushi
Contributor III

I am using the MC9S08DZ60<http://cache.freescale.com/files/microcontrollers/doc/data_sheet/MC9S08DZ60.pdf>. I have been give a circuit diagram according to which i must program the micro-controller. I am using Code warrior with Processor Expert which allows me to initialize the required registers, i don't have to write the code for the same.

Requirement from the code: Detect a PWM pulse on pin 0 of register D. In response, switch on LED and apply PWM signal on pins 3,4,5,6 of Register A. According to the datasheet, i have equated the value of the Channel value registers to the expected pin on the microcontroller.How to apply PWM signal at the required PIN ?I have made an attempt for the same in the following code.

Please refer to the given code:

unsigned int result; 
unsigned int pwmSignal() 
{ If(PTDD_PTDD0) // to check for the incoming PWM signal.
 { PTDD_PTDD2 = 1;  //light up LED.  
do // check Channel for 300ms.
 { //my understanding is to latch the values of the channel value registers to the expected pin.
 result = TPM2C0VH;
 result <<=8; 
result = result + TPM2C0VL; 
result = PTAD_PTAD4;
result = PTAD_PTAD5; 
} while (TPM2C0_CH0F == 0); 
else PTDD_PTDD2 = 0; 
}
}

The code compiles absolutely fine. but i dont see any change. At this point i wanna tell, this is my first attempt at doing this.

Also i have one more question, how do i use, for example PIN 2 of Register D, for two different operations in a single main.c ?? Please let me know if i can provide anymore data about all of the above. Thanks in advance!

Labels (1)
0 Kudos
0 Replies