FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [October 2005 Threads] 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.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|