I'm using stm33F7 reading sensor via SPI communication, it's working in slave only receive mode, I can read data in interrupt mode perfectly without os, but as I enable FreeRTOS (using STM32CUBE) after a random time interrupt stops firing. I'm also reading data from another sensor via UART communication with and without os, and in both modes it works fine, Is there any problem with using SPI Interrupt and FreeRTOS?
Is the interrupt handler using FreeRTOS API calls? If so you need to ensure the priority is set appropriately and that the STM32 has all priority bits set as preemption priority. This is described on the FreeRTOS website. Additionally, familiarise yourself with the FreeRTOS FAQ that covers common issues and how to detect them.
I solved my problem by changing SPI Interrupt Priority to 0. It's working perfectly now.
Related
I have MCU STM32F415xx and was trying to write on internal flash. But for reason I don't know PGPERR and PSGERR flags were turning on in random time (as I found, problem can be found anywhere in HAL libraries) and HAL functions were stopping. I turned out flags checkout in FLASH_WaitForLastOperation. And after that MCU is not responding on any try to connect. Reference manual says, that if this flags are on, flash operations just will not be performed, but my MCU is not working and I cannot connect to it with ST-LINK Utility (and Programmer as well) even with reset pin. So what could happen and is there any way to reanimate my MCU?
I am using STM32H7 family of microcontroller as SPI Master Transmit device which needs to talk to 4 SPI slave devices receive only which are also all STM32H7 MCU's. Both master and slave are configured for software slave management.
The confusion is how slave will identify when master wants to talk to it or transmit data to it without using hardware NSS pin?
How slave device will start receiving in this scenario and stop receiving when all data transmitted?
If you use software slave select (NSS), you must select and deselect the SPI interface by software.
Typically, you would setup an external interrupt on the pin used as NSS/CS and select/deselect the SPI interface when the interrupt is triggered.
On an STM32F1 chip, the SPI interface is selected/deselected by setting/clearing the SSI bit in the SPI_CR1 register. I assume it's very similar on a STM32H7 chip.
Update
I've just checked the STM32H7 and it's exactly the same.
It is very simple. Every slave has one pin called CS. You need to select this device by setting this pin just by using the GPIO. Then you can transmit or receive data. Remember that master has to supply clock even if it wants only to receive data.
It seems that the code shown below can manage the problem.
__HAL_SPI_ENABLE(&hspi1);
__HAL_SPI_DISABLE(&hspi1);
Can a device connected to main processor can initiate a i2c communication.
For example, FAN connected using i2c bus, is it possible for a FAN to send a feedback to main processor.
Common solution to a problem like this is to have a separate interrupt line.
I3C supports in-band interrupts, if you're not set on I2C yet.
The Arm processor on one of our boards has an spi port with two chip select lines.
It is mentioned in the processor's datasheet that it can control upto two spi devices.
Is it possible to use a GPIO as a slave select for an additional spi device?
How to modify the existing libraries/device drivers to support this change?
So far i've found a file in the kernel's source which contains the addresses of SPI port pins. Can anyone plz tell in which direction should i proceed?
If you have enough pins, you can bitbang the whole SPI protocol and use as many CS as you need.
You don't mention what processor it is. You have three possibilities.
If the processor has an i/o mux capabilities, turn off the SPI chip select functionality. The SPI controller will think it has asserted the line, but it won't go external.
Don't connect one SPI chip select. Use a pull-up/down for ESD protection.
Multiplex the chip select as per Joachim Isaksson
In first two cases, connect GPIOs to the additional device's chip select. Toggle the GPIO manually before running spi_write(), etc. This will allow the SPI controller to transfer at higher rates than are possible with bit banging and is a better system design. Ie, lower power consumption, lower CPU use, faster data rates, etc. If the peripheral is just for setup/boot, then the bit banging makes sense for simplicity. However, if your main operation depends on the SPI bus, you could consider this solution.
If only one peripheral needs the SPI for setup AND you have the i/o mux, you can disable the chip select functionality during setup, using a GPIO to select the setup peripheral and then re-enable the spi chip select during standard system operation for the other peripheral.
Using a GPIO doesn't require user space intervention. Drivers can provide call backs to set the GPIO when in use, so SPI commands can be buffered/queued and these solutions still work. For instance, the IMX SPI driver supports GPIO toggle by passing a negative chip select number to denote a GPIO id.
Note: Some SPI devices may require the chip select to toggle between words; what ever a word is for the device. Some controller may leave the chip select asserted when transferring multiple words. You need to get this right if you use a GPIO to manually select devices. I am sure some standard defines this, but definitely some device don't follow the standard.
Addendum: Most drivers support a GPIO chip select; via a negative chip select value. They will call Linux GPIO functions. Write a GPIO handler that does the de-multiplexing. No need to alter the SPI drivers.
Is there a sample i2c master code that supports rtc s35390a hardware clock? I am currently working on an SOC that needs to support s35390a from Seiko. But currently, i am getting an error rtc-s35390a 0-0030: hctosys: unable to read the hardware clock. I cannot read/write data properly. I am implementing combined form of transmission.
Use oscilloscope to check if I2C SCL/SDA show some thing
If you can get the first address correct waveform, You will easy to get the register value
This might not be a rtc chip problem.