just received my first XIAO board and I’m quite impressed with its performance so far.
As I want to use it to manipulate an incoming 800 Hz PWM signal (connected to an input pin set up for trggering pin change interrupts) I’m looking for a way to access (i.e. read from and write to) the digital IO pins directly without using digitalRead/digitalWrite.
Is there a similar approach as for Arduinos where one can use
for example PORTB = PINB | B00100000 to set a bit?
thanks for the feedback, just tested the proposed code and it executes ~ 1 us faster than digitalWrite.
Going to explore the speed up potential some more.
Can you present here piece of your code where you are using this approach in order to make your code faster?
The proposed code is somehow unclear for me to understand…
sorry for the late response, was quite busy at work … Anyhow, I’ll paste my code below, as mentioned in the original post I want to modify the duty cylce of an incoming PWM signal while keeping its frequency constant. You will find both methods (“Arduino style” and “fast style”) for setting the GPIO pin.
If you are using the Arduino IDE you can also have a look at “wiring_digital.c” which can be found under “AppData\Local\Arduino15\packages\Seeeduino\hardware\samd\1.7.9\cores\arduino”