I’m trying to run a simple example with queues using Atmega32.
I have
1. Two sending tasks
2. One receiving task
3. Buzzer
4. 3 LEDS (for errors detection)
The first sending task turns on the buzzer. The second sending task turns off the buzzer.
The receiver task receive execution code from either one of the sending tasks and act according to that code (0x01 to turn on buzzer , 0x02 to turn off buzzer).
The 3 leds are for error detection.
1. Pin 5 led -> queue empty (Receiver side)
2. Pin 6 led -> queue not empty (when it should be) (Receiver side)
3. Pin 7 led -> queue is full (Sender side)
The receiver task has higher priority than the two sender tasks. And it waits for 100ms in block state till any data arrives in queue.
The problem is, I always get pin (5) led on !! meaning the queue is empty. Where I thing the buzzer should go on and off without toggeling any leds for errors.
My assumption that the two sender tasks never run and the schedular always run the receiver (having the highest priority), but again there’s (100ms) for the receiver in block state where the two sender should operate.
Here’s my code:
~~~~
define F_CPU 8000000UL
include <avr/io.h>
include “freertos/FreeRTOS.h”
include “freertos/task.h”
include “freertos/queue.h”
include “freertos/FreeRTOSConfig.h”
void task
sender(void *pvParameters);
void taskreceiver(void *pvParameters);
QueueHandle
t myqueue;
int main(void)
{
my
queue = xQueueCreate(1, sizeof(char));
if(myqueue != NULL) {
DDRD = 0xf0;
char sender
one = 0x01;
char sendertwo = 0x02;
xTaskCreate(task_sender, NULL, 50, &sender_one, 1, NULL);
xTaskCreate(task_sender, NULL, 50, &sender_two, 1, NULL);
xTaskCreate(task_receiver, NULL, 50, NULL, 2, NULL);
vTaskStartScheduler();
}
return 0;
}
void task
sender(void *pvParameters)
{
char msg = ‘