Quality RTOS & Embedded Software

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




Loading

addiing support for i2c communication to RTOS

Posted by CMOS on February 19, 2008
hi,
im working with MPLAB port of RTOS and it works fine. the device im using is 18f4455. i need to extend the functionality of RTOS with i2c support for this (or for whole 18F devices) device. however im not exactly sure how this kind of kernal level functionality should be added to RTOS. So im looking for some advice/tutorials on how to get started.
and also please let me know if there are already written extensions for i2c for MPLAB port and 18F devices.


thanks
CMOS

RE: addiing support for i2c communication to RTOS

Posted by Dave on February 19, 2008
You should find a demo UART driver for each port in the download that can be used as a model for all drivers. Also take a look at the WIZNET demo source code as this includes an I2C driver, although the syntax will be different as its running on an ARM it will give you the basics.

RE: addiing support for i2c communication to RTOS

Posted by Anuradha on January 11, 2011
Hello,

Am not clear in what you have meant as "WIZNET" :-Q

RE: addiing support for i2c communication to RTOS

Posted by Jack Peacock on January 11, 2011
A few years ago I added I2C to FreeRTOS for an STR750 (ARM7TDMI). The concept was a device driver that ran a "transaction" with a peripheral device: send command, wait for response. I used a mutex flag to serialize access to the device driver, and a completion semaphore to block the originating task until the transaction completed (or timed out). The data transfer was handled in an interrupt service routine which set the completion flag when the I2C was done.

The mutex was needed because I had two devices on the I2C bus, with a separate task for each device. The mutex ensured that commands and responses were in serial order and data went to the right task. Both tasks used the same completion flag but since the mutex blocked the second task while the first was using I2C there was no conflict.

The other trick on I2C is being able to recover from a fault. In my case I had to shut off the I2C logic, switch to bit bang mode, and manually clock out 9 bits to clear the I2C bus if a peripheral hung (it happens, don't expect perfection). Without the timeout if a peripheral fails to respond to a command the bus hangs forever waiting for the response.
Jack Peacock


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




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

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

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