Go Down

Topic: PWM (Read 103 times) previous topic - next topic

edgar1421

Hello,

I've been looking for the forum to generate a 1MHz wave with PWM, but I'm not clear.


I want the digital Pin 9 to generate the wave at 1Mhz if possible.


I found a fragment of code, where you change the frequency on all the pins, in which it says that, you have to change the PWM and TC frequencies of the variant.h file. This is true?

Code: [Select]

/*
 * PWM
 */
/*
 * PWM
 */
#define PWM_INTERFACE PWM
#define PWM_INTERFACE_ID ID_PWM
#define PWM_FREQUENCY 20000
#define PWM_MAX_DUTY_CYCLE      4095
#define PWM_MIN_DUTY_CYCLE 0
#define PWM_RESOLUTION 12

/*
 * TC
 */
#define TC_INTERFACE            TC0
#define TC_INTERFACE_ID         ID_TC0
#define TC_FREQUENCY            20000
#define TC_MAX_DUTY_CYCLE       255
#define TC_MIN_DUTY_CYCLE       0
#define TC_RESOLUTION         8




Any idea how to do it?

Thanks


Go Up