What is wrong with this simplified Embedded C code? void interruptHandler() { //
ID: 3725849 • Letter: W
Question
What is wrong with this simplified Embedded C code?
void interruptHandler()
{
// write to a register on hardware
// to enable functionality
delayInSeconds(1); // delay for 1 second
// read value back
}
void main()
{
while (1)
{
// write to a register on hardware
// to enable functionality
delayInSeconds(1); // delay for 1 second
// read value back
// do something else
}
}
unsigned int timerTicks = 0;
void timerInterruptHander(void)
{
timerTicks++;
}
void main()
{
unsigned int initialTicks = timerTicks;
while (1)
{
if ((initialTicks + 10) < timerTicks)
flashLED(); // function defined elsewhere
}
}
Explanation / Answer
In above code there is a two main function please check it you should have one main function only
and the interruptHandler should be called from the first main function inside the while loop and delete the same code written in that while loop
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.