Why do i get error (void setupTimer() & void TC3_Handler ()) working with Arduino nano 33 iot board but not on Due board with same code?

<<<
´´´
#include <Arduino.h>  
// H-Bridge output pins (Use PWM-capable pins!) 
#define DCMOT_EN 4 
#define DCMOT_A 2 
#define DCMOT_B 3 
// Reflex-coupler input pin 
#define DCMOT_PULS 5  
#define poti A0
#define freq 1
static unsigned long counter_ = 0;

void zaehler();

void zaehler() //zaehler für Counter
{
    counter_ ++;
}

void setupTimer (Tc *tc, uint32_t channel, IRQn_Type irq, uint32_t frequency)
{
pmc_set_writeprotect (false);
pmc_enable_periph_clk((uint32_t) irq);
NVIC_EnableIRQ(irq) ;
TC_Configure(tc, channel, TC_CMR_WAVE | TC_CMR_WAVSEL_UP_RC | TC_CMR_TCCLKS_TIMER_CLOCK4);
uint32_t rc = (uint32_t) VARIANT_MCK/128/frequency; // (because TIMER_CLOCK4 = MCK/128)
TC_SetRA(tc, channel, rc/2); //50% high, 50% low
TC_SetRC(tc, channel, rc); // set RC (compare vaule)
TC_Start(tc, channel);
tc->TC_CHANNEL[channel].TC_IER=TC_IER_CPCS; // RC compare IRQ
tc->TC_CHANNEL[channel].TC_IDR=~TC_IER_CPCS; // disable all other IRQ sources
}

// Interrupt Service Routine for TC3-IRO

void TC3_Handler ()
{
TC_GetStatus(TC1, 0) ;
Serial.println( "Drehzahl pro minute=");
Serial.println((counter_ /8)*60);
counter_ =0;//zürücksetzen des counters
}
>>>
void setup() 
{   // start UART-monitor   
Serial.begin(9600);    
// configure pins   
pinMode(DCMOT_EN, OUTPUT);   
pinMode(DCMOT_A, OUTPUT);   
pinMode(DCMOT_B, OUTPUT);   
pinMode(DCMOT_PULS, INPUT); // pull-up not required 
pinMode(poti, INPUT);

setupTimer(TC1, 0, TC3_IRQn, freq);
Serial.print("1=links\n");
Serial.print("2=stopp\n");
Serial.print("3=rechts\n");

attachInterrupt(digitalPinToInterrupt(DCMOT_PULS), zaehler, FALLING);
}  

void loop() 
{   
    static uint32_t motorMode = 0;   
    static uint32_t UI_ActionFlag = 0;    
    //int speed = analogRead(poti)/4; //liest potentiometer [0-1023] und wandelt in 0-255 Bereich,
    // angeschlossen in 3.3V
    // int speed = 255; // fest geschwindigkeit
    // === UI ===============================================   
    int speed = 128;
    if (Serial.available())   
    {     
        UI_ActionFlag = 1;     
        switch (Serial.read())     
        {     
            case '3': // rechts
            motorMode = 3;
            break;

            case '1': //links
            motorMode = 1;
            break;

            case '2': //off
            motorMode = 2;
            break;

            default:       
            UI_ActionFlag = 0;       
            break;     
        }   

    }   

    // === UI ===============================================    
    // === Update Motor Mode ================================   
    // if (UI_ActionFlag)   
    if (true)
    {     
        switch (motorMode)     
        {   
            case 1:
            analogWrite(DCMOT_EN, speed);
            digitalWrite(DCMOT_A, HIGH);
            digitalWrite (DCMOT_B, LOW) ;
            break;
    
            case 3:
            analogWrite(DCMOT_EN, speed);
            digitalWrite(DCMOT_A, LOW);
            digitalWrite (DCMOT_B, HIGH) ;
            break;

            case 2:        
            digitalWrite(DCMOT_EN, LOW );       
            break;     
    
        }  
    }   
    // === Update Motor Mode ================================ 
    }
 ´´´
>>>

platformio.ini for due board

[env:due]

platform = atmelsam

board = due

framework = arduino

platformio.ini for nano board

[env:nano_33_iot]

platform = atmelsam

board = nano_33_iot

framework = arduino

A DUE (ATMEL SAM3X8E) des not equal a Nano (ATMega4809)

How do i get my error get corrected?

Write timer code for the Due.

The search box is a useful tool.


For instance, using the words "9v battery" in the search box one could find lots of reasons why this may be a bad idea.

Other search words include "level shifter", "round", "millis()", "DUE timer"

It's a Nano 33 IoT (SAMD21G18) :wink: But your point is very valid :+1:

Thanks for the info.

Life is very complicated nowadays with all those different Nanos.

:frowning_face: :frowning_face: :frowning_face: