Convert AVR sketch to ESP32

dfrenkel
Posts: 12
Joined: Sun Jul 22, 2018 1:52 pm

Convert AVR sketch to ESP32

Postby dfrenkel » Sun Jul 22, 2018 2:05 pm

I have a sketch that is used to control an SPI device. The problem is that the author wrote it for an ATmega 328p. I am fairly new to all of this, so how can I go about finding the registers to switch from the 328p to ESP32?

Here is the section of code that utilizes registers for the 328p:

Code: Select all

  // Set stepper interrupt
  {
    noInterrupts());//stop interrupts
    TCCR1A = 0;// set entire TCCR1A register to 0
    TCCR1B = 0;// same for TCCR1B
    TCNT1  = 0;//initialize counter value to 0
    OCR1A = 60;// = (16*10^6) / (1*1024) - 1 (must be <65536)
    // turn on CTC mode
    TCCR1B |= (1 << WGM12);
    // Set CS11 bits for 8 prescaler
    TCCR1B |= (1 << CS11);// | (1 << CS10);  
    // enable timer compare interrupt
    TIMSK1 |= (1 << OCIE1A);
    interrupts();//allow interrupts
  }

Deouss
Posts: 425
Joined: Tue Mar 20, 2018 11:36 am

Re: Convert AVR sketch to ESP32

Postby Deouss » Sun Jul 22, 2018 8:42 pm

To me looks like simple timers setup but in a way it targets almost assembler style code because atmega is slow chip.
I'd post it on arduino.cc forums

Who is online

Users browsing this forum: No registered users and 64 guests