This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to generate the frequency from 3hz to 6hz with the step size of 0.5hz

Hi,

Below is the code where I'm getting the desired frequency by varying PR and MR3
registers...
Like by going through the user manual got to know that FCLKOUT is 48 MHz,
so to get the output of 3Hz need to assign values to prescaler & match register
respectively i.e., 48 Mhz/4000*4000 = 3Hz.

So now my problem is how to generate the frequency continuously from 11hz to 13hz,
or 3hz to 6hz with step variation of 0.5[i.e., 3hz,3.3hz,4hz,4.5hz etc..]
Should I use timer for this operation or interrupts.
Please do suggest me.

#include <LPC11xx.h>            /* LPC11xx Peripheral Registers */
#include "system_LPC11xx.h"

int main()
{
SystemInit();
LPC_SYSCON->SYSAHBCLKCTRL |= (1<<16) |(1<<6) | (1<<8) ;
LPC_IOCON ->PIO1_9 |= (1 << 0);             //PIN1_9 = CT16B1_MAT0
LPC_TMR16B1 ->MR0 = 1000;                   //50% Duty Cycle
LPC_TMR16B1 ->PR = 2000;//for 12hz freq
LPC_TMR16B1 ->MR3 = 2000;//for 12hz freq    //Cycle Length
LPC_TMR16B1 ->MCR |= (1 << 10);             //TC Reset on MR3 Match
LPC_TMR16B1 ->PWMC |= (1 << 0);             //PWM Mode
LPC_TMR16B1 ->TCR |= (1 << 0);              //GO
}


Regards,
Angiey