Hello Arduino Community,
I have tested the interrupt on pin 53 on two due and it is not working. On all the other pins however it is working. Has anybdy else this problems?
Hello Arduino Community,
I have tested the interrupt on pin 53 on two due and it is not working. On all the other pins however it is working. Has anybdy else this problems?
Hello,
I have the same problem. I want to use encoder on pin 53 but it is not working. Do you think that it can be related to this topic : Documentation Interrupts mainly DUE · Issue #5071 · arduino/Arduino · GitHub ?
For a proper signal handling, an interrupt pin should have a Schmitt Trigger, so yes your issue is certainly related to that topic. However, attachInterrupt() is relatively "slow", therefore you can't detect with a good accuracy input trigger with this function for frequencies above several tens of KHz.
You can try to modify the trigger input frequency with this sketch so that the board produces and detects the input trigger (here on D24, a "Schmitt Trigger" pin"):
/*******************************************************************/
/* Hook a jumper between pin 24 and pin 2 */
/*******************************************************************/
void ISR1() {
static uint32_t Count;
if (Count++ == 65625) { // MCK/128/TC_RC
Count = 0;
PIOB->PIO_ODSR ^= PIO_ODSR_P27; // Toggle LED with a 1 Hz frequency
}
}
void setup() {
pinMode(24, INPUT);
pinMode(LED_BUILTIN, OUTPUT);
PMC->PMC_PCER0 |= PMC_PCER0_PID12; // PIOB power ON
PIOB->PIO_OER |= PIO_OER_P27;
PIOB->PIO_OWER |= PIO_OWER_P27;
/************* Timer Counter 0 Channel 0 to generate PWM pulses thru TIOA0 ************/
PMC->PMC_PCER0 |= PMC_PCER0_PID27; // TC0 power ON - Timer Counter 0 channel 0 IS TC0
PIOB->PIO_PDR |= PIO_PDR_P25;
PIOB->PIO_ABSR |= PIO_ABSR_P25;
TC0->TC_CHANNEL[0].TC_CMR = TC_CMR_TCCLKS_TIMER_CLOCK4 // MCK/128, 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 TIOA0 on RA compare match
| TC_CMR_ACPC_SET; // Set TIOA0 on RC compare match
TC0->TC_CHANNEL[0].TC_RC = 10;//<********************* Frequency = (Mck/128)/TC_RC Hz
TC0->TC_CHANNEL[0].TC_RA = 1;//<******************** Duty cycle = (TC_RA/TC_RC) * 100 %
TC0->TC_CHANNEL[0].TC_CCR = TC_CCR_SWTRG | TC_CCR_CLKEN; // Software trigger TC0 counter and enable
attachInterrupt(24, ISR1, RISING);
}
void loop() {
}
An input capture with a timer counter can detect much higher frequencies. Are you using a quadrature encoder ?