Reference no: EM132190085
Goal:
In this project you will create an OS-driven multitasking device than can capture data at precise intervals and send data over a serial interface to a computer, while (for extra credit) playing delightful music and riveting games. If more extra credit is desired, buffering the data to EEPROM may be attempted.
Description: Overview
In this project you will create an OS-driven multitasking device than can capture data at precise intervals and send data over a serial interface to a computer, while (for extra credit) blinking a light and playing games. If more extra credit is desired, buffering the data to EEPROM may be attempted. The device will boot into a menu 3 (5 for extra credit) commands are available. This menu serves as the command prompt on a traditional linux system. These commands initiate and suspend tasks. You'll need to perform the following steps to complete the project - any thing in RED is required, everything else is extra credit.
- (EC) Create/add tasks to run provided light and game functions in the OS skeleton code
- Setup ADC and Timer0 to implement precision capture intervals
- Implement a circular buffer in RAM (you may do this in EEPROM for extra credit)
- Create Task to poll and store ADC data into the circular buffer
- Create Task to dequeue data from the circular buffer and send data through serial port at a sufficient rate to avoid overflow
- Implement a menu system (MAIN MENU) using the LCD and Joystick with these 5 commands:
o CAPT- Resumes Capture task (stay at prompt. task suspends itself if circular buffer fills)
o STSD - Resumes Send task (stay at prompt, task runs until suspended)
o SPSD - Suspends Send task (stay at prompt, suspends send task)
The only tasks that you need to do on this project is the required tasks only.
The code should be written in C.
You are provided all the code for:
1- Timer0
2- ADC code
3- LCD
4- UART
All other AVRx codes.
Task Details:
The main menu command driven task control menu should be implemented using a AVRX tasks and should control other AVRX tasks
Implement a menu system (MAIN MENU) using the LCD and Joystick with these 5 commands:
- CAPT- Resumes Capture task (stay at prompt. task suspends itself if circular buffer fills)
- STSD - Resumes Send task (stay at prompt, task runs until suspended)
- SPSD - Suspends Send task (stay at prompt, suspends send task)
Capture TASK
If user selects the capture command, the task for capturing the temperature of the surrounding will start and it will continue to execute as long as there is a free room in the circular buffer. In other words, capture task will suspend itself if there is no room in the buffer, and will continue to run forever if it always finds a free room in the buffer. If you do choose to go for extra credit, EEPROM is available in ATmega169P. Check the datasheet for more info.
ADC and Timer0: :
- Setup ADC to Trigger off of Timer0, with a frequency around 30-32 Hz. You need to figure out how to trigger the ADC off of Timer0 and configure Timer0 accordingly. Set the autoconversion enable bit and set ADCSRB appropriately to select the timer signal source (check datasheet).
- You can trigger the ADC off of Timer0 overflow or output compare match. IMPORTANT NOTE: You will need to have an ISR for whatever interrupt you choose to use because the code will enter there despite the use of auto conversion. You don't need to have any code in the ISR, it just needs to be defined.
- Set the prescalar value, ADPS, to make sure the ADC clock is below the specified 200kHz to achieve full accuracy.
- Set the reference to the internal 1.1V using the REFS bits.
Send Data TASK
Starting/Resuming Send Data: Enabled by sending STSD. This will start a task which will read the captured data from the buffer (implemented in EEPROM if attempting extra credit, but in normal RAM processes if not) and will send it via serial port to the PC. On the PC side an application will listen to the port and will capture the data.
The Sending-Data task will not halt/terminate even if it finds the buffer empty (underflow). It should wait and send new data in the buffer to the PC as it becomes available.
Suspending Send Data: This command will suspend the send-data task if it is running. The side effect of this action will be a full buffer if the Capture Task is still running. A full buffer will cause the Capture Task to be suspended until space in the buffer is available.
Attachment:- PROJECT.rar