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

Jsp - quiz, JSP QUIZ ASSIGNMENT SHOULD BE FUNCTIONAL ON ECLIPSE QUIZ HAS ...

JSP QUIZ ASSIGNMENT SHOULD BE FUNCTIONAL ON ECLIPSE QUIZ HAS TOTAL 20 QUESTIONS REGARDING VARIOUS CAPITALS OF COUNTRIES. WELCOME PAGE OFFERS USER TO ENTER HIS NAME. THEN USER C

Program on car purchasing simulation, Introduction A new online syst...

Introduction A new online system for purchasing carsis being designed and you have been contracted to write a C# console application program that models the proposed functio

Define the if - else statement - computer programming, Define the If - else...

Define the If - else statement - computer programming? The If - else statement The universal form of if - else statement is                         if(expression)

econometrics using r, EF308 Assignment 2 Due: 3pm, 26 April 2012 Introduct...

EF308 Assignment 2 Due: 3pm, 26 April 2012 Introduction This assignment is loosely based on Cheung et al. (2005) and Molodtsova and Papell (2009) and examines the out-of- sample pr

Simple encryption, i have to make a program that encrypt a text to numbers,...

i have to make a program that encrypt a text to numbers, i don''t know what is wrong in my code, the example of what i need: text: hi >> number: 17 23

Assignment help, Write your own version of the strcmp function string_compa...

Write your own version of the strcmp function string_compare. Supply a main program that will test each of the 3 differing outcomes. int string_compare(char *s, char *t); retu

No Linux Audible, Why no Audible support for Linux? Maybe they should use a...

Why no Audible support for Linux? Maybe they should use a browser interface?

Function to check whether a certain ingredient is on pizza, Carnivorous Car...

Carnivorous Carla only eats pizza if it has at least three of the following ingredients: ham, pepperoni, salami, italian sausage, bacon. You have the function contains() to check w

Assembly TASM or MASM, I need help with making a assembly program that uses...

I need help with making a assembly program that uses Hoffman''s coding scheme to compress a text file.

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