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?
I'm confused by you saying your question is very basic, it is not the kind of question I'd call basic, more like advanced.
Read the data sheet for the processor. The registers have names, those names will correspond to variable names when you write code, so if you want to write 0x01 to the TTR (I made that up) register you just use:
TTR = 0x01;
As to what the registers do and how you get them to do it the data sheet will tell you.
Assuming that you are in the Arduino IDE and use pinMode() to set the pins to the appropriate direction, you should be able to to access the "direct port registers" with code like:
GPIOA->ODR |= 0x20; // set bit using logic to Output Data Register
GPIOA->ODR &= ~0x20; // clear bit using logic
GPIOA->BSRR = 0x20; // Set bit atomically via set/reset register
GPIOA->BRR = 0x20; // clear bit atomically via reset register.
bool pin5 = !!(GPIOA->IDR & (1<<5)); // read pin via input data register.
(You'll have to translate "Arduino pin numbers" to STM32 Port/Bit manually, as appropriate for your board, I guess.)
There is an educational company that has a bunch of classes centered around programming the the ST ARM microcontrollers. They have some "freebies" that are ... not bad at all, especially in that they provide extensive references to the datasheets for each line of code. Worth giving them your info and putting up with some subsequent advertisements for their for-pay classes, IMO...
(Those are actually for STM32F4xx, but should be equally applicable to STM32F3xx)
The HAL hardware abstraction layer, enabling portability between different STM32 devices via standardized API calls
The Low-Layer (LL) APIs, a light-weight, optimized, expert oriented set of APIs designed for both performance and runtime efficiency
CMSIS device definition for STM32
CMSIS: Cortex Microcontroller Software Interface Standard (CMSIS) is a vendor-independent hardware abstraction layer for the Cortex®-M processor series and defines generic tool interfaces. It has been packaged as a module for Arduino IDE: GitHub - stm32duino/ArduinoModule-CMSIS: CMSIS module for Arduino IDE