Convert AVR sketch to ESP32
Posted: 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:
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
}