You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My motor is too load when I drive it by Arduino Due PWM waveform. The issue is that the default PWM frequency of Ardunio Due is 1000. I am wondering how can I increase that? I used this code in my sketch to make the interrupts but did not work.
void setupTimerPWM(){
PMC->PMC_PCER1 |= PMC_PCER1_PID34; // TC7 power ON - Timer Counter 2 channel 1 IS TC7 - See page 38
PIOC->PIO_PDR |= PIO_PDR_P28; // The pin is no more driven by GPIO
PIOC->PIO_ABSR |= PIO_PC28B_TIOA7; // Periperal type B - See page 859
TC2->TC_CHANNEL[1].TC_CMR = TC_CMR_TCCLKS_TIMER_CLOCK1 // MCK/2, clk on rising edge
| TC_CMR_WAVE // Waveform mode
| TC_CMR_WAVSEL_UP_RC // UP mode with automatic trigger on RC Compare
| TC_CMR_ACPA_CLEAR // Clear TIOA7 on RA compare match -- See page 883
| TC_CMR_ACPC_SET; // Set TIOA7 on RC compare match
Hi,
My motor is too load when I drive it by Arduino Due PWM waveform. The issue is that the default PWM frequency of Ardunio Due is 1000. I am wondering how can I increase that? I used this code in my sketch to make the interrupts but did not work.
void setupTimerPWM(){
PMC->PMC_PCER1 |= PMC_PCER1_PID34; // TC7 power ON - Timer Counter 2 channel 1 IS TC7 - See page 38
PIOC->PIO_PDR |= PIO_PDR_P28; // The pin is no more driven by GPIO
PIOC->PIO_ABSR |= PIO_PC28B_TIOA7; // Periperal type B - See page 859
TC2->TC_CHANNEL[1].TC_CMR = TC_CMR_TCCLKS_TIMER_CLOCK1 // MCK/2, clk on rising edge
| TC_CMR_WAVE // Waveform mode
| TC_CMR_WAVSEL_UP_RC // UP mode with automatic trigger on RC Compare
| TC_CMR_ACPA_CLEAR // Clear TIOA7 on RA compare match -- See page 883
| TC_CMR_ACPC_SET; // Set TIOA7 on RC compare match
TC2->TC_CHANNEL[1].TC_RC = pwmRange; //<********************* Frequency = (Mck/2)/TC_RC Hz = 20 KHz
TC2->TC_CHANNEL[1].TC_RA = 1; //<******************** Duty cycle = (TC_RA/TC_RC) * 100 %
TC2->TC_CHANNEL[1].TC_IER = TC_IER_CPCS; // Interrupt on RC compare match
NVIC_EnableIRQ(TC7_IRQn);
TC2->TC_CHANNEL[1].TC_CCR = TC_CCR_SWTRG | TC_CCR_CLKEN;// Software trigger TC7 counter and enable
}
// interrupt handler
void TC7_Handler() {
static uint32_t Count;
TC2->TC_CHANNEL[1].TC_SR;
}
The text was updated successfully, but these errors were encountered: