Open Geekoid85 opened 6 years ago
The example uses direct register manipulation to write to pins much faster than digitalWrite
can.
PORTF is found on Arduino Mega and you need to modify the port and port bit to suit your board. You can find the needed information by searching for the pinout diagram.
Actually it's an arduino UNO, but in the future an esp32. On the official arduino documentation I only found PORTB or PORTD. What about PORTF ? That's a new technique for me, sorry for there approximation https://www.arduino.cc/en/Reference/PortManipulation
The example is written for Arduino Mega. PORTF, bit 0 corresponds to D54/A0 as shown in the pinout diagram.
Ok thank you, I understand. There ports is needed for the enable, step, dir and cs pins ? The spi pins or both ?
The step port is the only one that you need to worry about as it is the only one that needs to be driven quickly.
Actually it's an arduino UNO, but in the future an esp32. On the official arduino documentation I only found PORTB or PORTD. What about PORTF ? That's a new technique for me, sorry for there approximation https://www.arduino.cc/en/Reference/PortManipulation
@Geekoid85 Have you figured out how to use this for ESP32 or UNO? I am very confused about this port manipulation and curious if you know how to do it now. Thanks!
You can replace it with the familiar digitalWrite
. It's not as fast but easier to use.
@teemuatlut I really appreciate your help and support.
If using a Nano, how can I change the following section to use digitalWrite:
ISR(TIMER1_COMPA_vect){
PORTF |= 1 << 0;
PORTF &= ~(1 << 0);
}
ISR(TIMER1_COMPA_vect){
digitalWrite(STEP_PIN, HIGH);
digitalWrite(STEP_PIN, LOW);
}
@teemuatlut
Thank you so much! I made the change, but it was still not working, so I defined the SPI pins and now it works!
byte MOSI_PIN = 11; //SDI/MOSI (ICSP: 4, Uno: 11, Mega: 51)
byte MISO_PIN = 12; //SDO/MISO (ICSP: 1, Uno: 12, Mega: 50)
byte SCK_PIN = 13; //CLK/SCK (ICSP: 3, Uno: 13, Mega: 52)
First, thanks for your job, it amazing to control the tmc2130 as simple as that but I have a small issues. When I compile the example sketch StallGuard the debug said PORTF is not declared. The library work just fine on the "simple" sketch and is apparently correctly installed. Any on can help me to understand my error ? Thanks for your time :+1: