arm - how to obtain a 100 hz square signal using pwm timer in lpc1114/333 -
i need please. new on arm. work on embedded project. in project using lpc1114 microchip , drv8821 drive stepper motor, need timer pwm square signal 100 hz. have been reading user manual lpc1114 , wrote code failed. code below please analyze code , me. stuck in project. abmotor step data sheet , project schematic pin 27 (pin 0_8)
#include "lpc11xx.h" int main(void) { //set 16 bit timer pwm operation lpc_iocon->pio0_8 = (lpc_iocon->pio0_8 & ~(0x3ff)) | 0x2; //set pin pwm use (sec 7.4.23) lpc_syscon->sysahbclkctrl |= (1<<7); //enable clock signal 16 bit timer0 (sec 3.5.14) lpc_tmr16b0->pr = 0x0; //set prescaler max value, not used here (sec 18.7.4) lpc_tmr16b0->mcr = 0x10; //set reset on counter match (sec 18.7.6) lpc_tmr16b0->emr |= 0x20; //set pin 27 1 on match (sec 18.7.10) lpc_tmr16b0->ccr = 0; //set timer mode (sec 18.7.11) lpc_tmr16b0->pwmc = 0x1; //set channel 0 pwm mode (sec 18.7.12) lpc_tmr16b0->mr1 = ???????; //set value period (sec 18.7.7) lpc_tmr16b0->mr0 = ??????; //set value duty cycle (sec 18.7.7) lpc_tmr16b0->tcr |= 0x3; //enable , reset counter (sec 18.7.2) lpc_tmr16b0->tcr &= ~(0x2); //clear reset bit (sec 18.7.2) while(1){ //infinite loop } return 0 ; }
when write code , see dc 2,68v in pin 27 oscilloscope screen. need square signal 100hz in pin. please me. @ least dont know value assign instead of question marks(mr1 , mr0) in code adjust signal 100hz frequency.
best regards,
Comments
Post a Comment