- Tue Dec 06, 2011 1:42 pm
#136666
I'm working on a project where I want to use the PWM1 of my LPC1769 to control a motor's speed (via a L298N driver). With various settings I can get an LED to dim, so I know my code works in general, but I cannot get the motor to rotate at different RPMs. On the L298N side, I am driving IN1/2 high/low (forward), OUT1/2 to my DC motor, CSA to ground and pulsing ENA. I have also tried leaving ENA high and pulsing IN1 instead but it made no difference.
Firmware wise, I am using CMSIS 1.3 and the LPC17xx CMSIS driver library. From the settings in the CMSIS code (which I did not bother to adjust), PCLK_PWM1 is running at 25MHz. I have enabled PWM1 and set MR0 to match at 25,000 (ticks) running in timer mode with no prescale, which as I understand it, should then be operating at 1kHz frequency. For the sake of testing, I have set MR1 to match at 6,250 (ticks) which should yield a 25% duty cycle (in reality this will be set based on an ADC input).
As I said, these hardware and software settings are not controlling the speed of the motor so I am not understanding something correctly about either the L298N or the LPC1769 PWM but I am not sure what that is. Any help is very appreciated.
Firmware wise, I am using CMSIS 1.3 and the LPC17xx CMSIS driver library. From the settings in the CMSIS code (which I did not bother to adjust), PCLK_PWM1 is running at 25MHz. I have enabled PWM1 and set MR0 to match at 25,000 (ticks) running in timer mode with no prescale, which as I understand it, should then be operating at 1kHz frequency. For the sake of testing, I have set MR1 to match at 6,250 (ticks) which should yield a 25% duty cycle (in reality this will be set based on an ADC input).
As I said, these hardware and software settings are not controlling the speed of the motor so I am not understanding something correctly about either the L298N or the LPC1769 PWM but I am not sure what that is. Any help is very appreciated.