Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

How to use CAN?

Posted by Nobody/Anonymous on October 20, 2005
Hi,

thanks a lot for your great FreeRTOS project. I'm working on a controller project that uses CAN. Are you aware of any applications that have used CAN within FreeRTOS tasks?

I would also like to interface SPI peripherals, but the two peripherals I plan to use would be used by differnt tasks (one is a sensor with an integrated AD converter, the other an SPI based flash for logging). How could this be done?

RE: How to use CAN?

Posted by Richard on October 20, 2005
>I'm working on a controller project that uses CAN

I think this is something that has been discussed here before, or maybe it was on the LPC2000 forum? Unfortunately CAN is not easy to use as a search term as nearly every post is returned.

Using CAN should be straight forward. The preferred method of processing peripherals is to have a very short interrupt routine that reads the data from the peripheral, clears the interrupt, then sends the data to a task for processing at the task level. How the data is sent to the task is dependent on your project requirements. You can use a queue or a simple circular buffer. The queue has a slightly higher time overhead, but allows the task waiting to receive the data to be woken as soon as data is received, and if necessary run immediately that the ISR has completed (if its priority is higher than the interrupted task). A simple circular buffer efficient, but you don't get the automatic task notification. You can use the UART driver sample to see the necessary syntax for your particular part and compiler.


>I would also like to interface SPI peripherals, but the
>two peripherals I plan to use would be used by
>differnt tasks (one is a sensor with an integrated AD
>converter, the other an SPI based flash for logging).
>How could this be done?

All you have to watch out for is that both tasks don't attempt to use the SPI at the same time. One way of doing this is to not access the peripheral directly but instead use queues, as per the UART example. The SPI send function can just write the data to a queue. The SPI driver then reads the data from the queue. The driver then guarantees sequential access with one message being processed at a time. You can queue a pointer to a structure of the form:

{
char cDestination;
char *pcData;
int iDataLength;
}

When the driver obtains this from the queue, it then knows which peripheral to send the data to, where to obtain the data to be transmitted, and how much data to send.

Regards.



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




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

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

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

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

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists