Hello Mates,
i have TM4c1290NCPDT TIVA ware uC which i want to use to generate the Square wave signal with Desired Freq but with Fine Accuracy i.e. i want to use it with 50 Khz and Also with 5Khz too but with accruacy of +/- 0.1Hz.
I have use the PWM Generator Block for the same.
But it will not work properly.
Please help me for the same.and if any example code .
Below is my Code but i didn't got the exact 4KHz. If i want exact 4KHz how could i be able to achieve?
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0); ROM_PWMClockSet(PWM0_BASE, PWM_SYSCLK_DIV_64); ROM_GPIOPinConfigure(GPIO_PG0_M0PWM4); ROM_GPIOPinTypePWM(GPIO_PORTG_BASE, GPIO_PIN_0); // // Configure the PWM generator for count down mode with immediate updates // to the parameters. // ROM_PWMGenConfigure(PWM0_BASE, PWM_GEN_2, PWM_GEN_MODE_DOWN | PWM_GEN_MODE_NO_SYNC); // // Set the period. For a 4 KHz frequency, the period = 1/4000, or 0.25 // milliseconds. For a (60MHz/64) clock, this translates to 937.5 clock ticks. // Use this value to set the period. // ROM_PWMGenPeriodSet(PWM0_BASE, PWM_GEN_2, (937.5/4)); // // Set the pulse width of PWM0 for a 50% duty cycle. // ROM_PWMPulseWidthSet(PWM0_BASE, PWM_OUT_4, (937.5/8)); // // Start the timers in generator 0. // ROM_PWMGenEnable(PWM0_BASE, PWM_GEN_2); // // Disable the outputs. // ROM_PWMOutputState(PWM0_BASE, PWM_OUT_4_BIT, false); // // Enable the outputs. // ROM_PWMOutputState(PWM0_BASE, PWM_OUT_4_BIT, true);