Program for nuclear reactor - embedded systems, Programming Languages

Assignment Help:

Implement the "Nuclear Reactor" example using the following:

 An ISR triggered by a button press
 A task to update the temperatures
 A semaphore to communicate between the ISR and the update task
 The update task should use dynamic memory allocation to get a buffer in which to place the temperature.
 Pass the buffer containing the temperatures to the checking task using an RTOS queue.

Write an "Introduction to using FreeRTOS" document in which you use your "Nuclear Reactor" code as an example to explain the key concepts of Semaphores, queues, dynamic memory allocation in an RTOS and timing in an RTOS.

This is a code: Nuclear reactor.
////////////////////////////////////////////////////////

////////////////////////////////////////////////////////

//// main.c

////////////////////////////////////////////////////////

////////////////////////////////////////////////////////

#include

/* Scheduler include files. */

#include

#include

#include

#include

/*-----------------------------------------------------------*/

voidTaskUpdatTemps(void *pvParameters);

voidTaskCheckTemps(void *pvParameters);

/*-----------------------------------------------------------*/

//global shared data

int temperatures[2];

//xSemaphoreHandle-Data structure managed by the RTOS

xSemaphoreHandletemperaturesSem;

xSemaphoreHandleReleaseSem;

ISR(INT0_vect)

{

 //Release the semaphore

 xSemaphoreGive(ReleaseSem);

}

intmain(void)

{

 //Set direction of PORTB pin 5,6,7 as output pins

 DDRB |= (1<
 DDRB |= (1<
 DDRB |= (1<
 //Generate in on rising edge on INT0 pin - bits in EICRA Reg

 EICRA |= (1 << ISC00);

 EICRA |= (1 << ISC01);

 //Enable - bits in EIMSK reg

 EIMSK |= (1 << INT0);

 //Enable interrupts - Set I bit in SR(status register)

 sei();

 xTaskCreate(

 TaskUpdatTemps

 , NULL

 , 256

 , NULL

 , 2

 , NULL );

 xTaskCreate(

 TaskCheckTemps

 , NULL

 , 256

 , NULL

 , 1

 , NULL );

 //Create semaphores

 vSemaphoreCreateBinary(temperaturesSem);

 vSemaphoreCreateBinary(ReleaseSem);

 //Start the task Scheduler

 vTaskStartScheduler();

/*while(1)

 {

 //do nothing

 }*/

}

/*-----------------------------------------------------------*/

voidTaskUpdatTemps(void *pvParameters)

{

//Just keep compiler happy

 (void)pvParameters;

 staticint count = 0;

while(1)

 {

 //Take the semaphore ReleaseSem

 xSemaphoreTake(ReleaseSem, portMAX_DELAY);

 //Take the semaphore temperatureSem to protect atomic variables

 xSemaphoreTake(temperaturesSem, portMAX_DELAY);

 temperatures[0]=count;

 temperatures[1]=count;

 //Give the semaphore back

 xSemaphoreGive(temperaturesSem);

 //Increment Count variable

 count ++;

 //Toggle portb pin 6 to turn LED on/off (Using Exclusive OR)

 PORTB ^= (1<
 //Delay for 1 sec

 //vTaskDelay( 1000 / portTICK_RATE_MS );

 }

}

/*-----------------------------------------------------------*/

voidTaskCheckTemps(void *pvParameters) // Main Green LED Flash

{

int temp0, temp1;

 (void) pvParameters;

//Set direction of pin to be an output

 DDRB |= (1<
while(1)

 {

 //Take the semaphore temperatureSem to protect atomic variables

 xSemaphoreTake(temperaturesSem, portMAX_DELAY);

 temp0=temperatures[0];

 //Delay for 1 sec

 vTaskDelay( 1000 / portTICK_RATE_MS );

 temp1=temperatures[1];

 //Give the semaphore back

 xSemaphoreGive(temperaturesSem);

 //Toggle portb pin 5 to turn LED on/off (Using Exclusive OR)

 PORTB ^= (1<
 //Checking to see if temperatures match

 if(temp0 != temp1)

 {

 PORTB |= (1<
 }

 }

}


Related Discussions:- Program for nuclear reactor - embedded systems

Develop an application for airraid game, Extend the AirRaid game, so that t...

Extend the AirRaid game, so that the planes drop a bomb on the gun as they go over it. The gun has to move out of the way otherwise it will be destroyed if hit. Provide three lives

Write a program that draws the initials j, Write a program that draws the i...

Write a program that draws the initials J G P on the form similar to that shown in Fig J 1 (using straight lines and curve semicircles). The figure can not have corners. All ends a

Develop a mobile phone application for games, You have been asked to set up...

You have been asked to set up a project plan for developing a mobile phone application for London Olympics. Major tasks include conducting some research into different mobile ph

Assembly language, I need help with having a user input a year, and my prog...

I need help with having a user input a year, and my program to spit out what day of the week Christmas is on.... any helping hands on this?

Define a procedure that takes three numbers as arguments, Translate the fol...

Translate the following formula into a prefix form expression in Scheme: Question 2 Define a procedure that takes three numbers as arguments and returns the sum of the squ

Little Man Computer, 1) Write a program that takes an input value (for exam...

1) Write a program that takes an input value (for example, a number 5). The output should be sum of all numbers from 1 to the value input by the user (in this example, the output w

Describe informally how to draw a pda diagram, Suppose L is a context-free ...

Suppose L is a context-free language and L' is regular. Show that L∩ L' is a context- free language. Specifically, if you're given a PDA diagram of L and a DFA diagram for L' , des

I need to do coding for the last three question, i attached the assignment ...

i attached the assignment document only i need your help with following three parts: accessible areas, accessible cul-de-sacs that are all connected, entry-exit path with no in

C programming assignments, I can attach or send the assignment instructions...

I can attach or send the assignment instructions, but they''re rather long. 90% of the code is already written and given to us. The assignment is primarily rewriting and rearrangin

Program for connect 4 game on a general board, The classical connect-4 game...

The classical connect-4 game is played on a 67 board, it can in fact be played in any nrRowsnrCols board. In your implementation, the user will specify the number of rows nrRows an

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd