Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


Loading

Sharing the SPI bus.

Posted by Nobody/Anonymous on July 19, 2006
Hi,

I'm new to FreeRTOS, I got up and running earlier today. I've just looked at the schematic for our board and realise that the 2 main peripherals on our system are on the same spi bus.

We're using the SAM7S series.

Bearing in mind that I will have different tasks handling both peripherals, what's the best way to attack this?

The way I see it is that I create a transmission queue, and when something wants to transmit on spi it adds the message to the queue. A task then takes the message from the queue (providing it's not currently transmitting) and transmits it. Reads from the bus are obviously done in a similar manner as they're dummy writes.

Once the message is fully read, it's place into the correct read queue for the peripheral and the task that deals with that peripheral awakes and processes the data.

Both peripherals can also cause interrupts, so when the interrupt occurs I have to set up the system to do a read.

Being new to using FreeRTOS (or any off the shelf RTOS) I'm wondering if I'm thinking in the right way or have I totally got it wrong! Any ideas or information on how other people have done this would be gratefully accepted.

Thanks.

Adrian

RE: Sharing the SPI bus.

Posted by Nobody/Anonymous on July 19, 2006
Some would approach this by having a semaphore to guard access to the bus. You must first obtain the semaphore before accessing the bus. This way any task can access it. Personally I think this is nearly always a bad idea.

Take a look at the UART drivers given as examples. These let any task send data to the UART without the risk of corruption by queueing data to transmit within a function (just a simple function, it does not need to be a task provided you use a scheduler lock around access). An interrupt can be used to read data from the queue directly.

Directing received data to the correct task is a little more complex and requires some decoding of addresses prior to posting onto a queue.

Also take a look at the I2C driver that is in the WizNET WEB server demo. This will give an example of how to send discrete framed messages rather than a single stream of bytes.


[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]


Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner