Direct register access on STM32 F302R8

Post here first, or if you can't find a relevant section!
Post Reply
StewMan
Posts: 1
Joined: Sat Mar 19, 2022 10:00 am

Direct register access on STM32 F302R8

Post by StewMan »

Hi im verry new to the world of micro controllers so sorry my questions are very basic.

im looking to connect to a rotary encoder for a motor driver but it has an SSI interface. ive writen a script that interprets SSI on a raspberry pi but in need to move it over to the STM F302R8 board. the script uses "bit banging" pins high and low for error checking and ensuring i'm reading the correct signal. using digital write is to slow (1 micro second)

i was wondering if anyone had a sort of guide to direct register access to help me understand it better and point me towards how to do it.

Also is there an equivalent process for reading pins?

Thanks for any help.
GonzoG
Posts: 403
Joined: Wed Jan 15, 2020 11:30 am
Answers: 27
Location: Prudnik, Poland

Re: Direct register access on STM32 F302R8

Post by GonzoG »

Use
digitalReadFast(pin_name);
digitalWriteFast(pin_name,value);

eg:

Code: Select all

digitalReadFast(digitalPinToPinName(PA1));
digitalReadFast(PA_1);

digitalWriteFast(digitalPinToPinName(PA1),true);
digitalWriteFast(PA_1,true);
With -O3 (fastest) optimization those execute in 1 CPU cycle.
Post Reply

Return to “General discussion”