<< Chapter < Page | Chapter >> Page > |
Write a function,
void seg_count(int num)
, similar to the LED counting function,
led_num()
, from
Lab 4 . In this case, the function will display a number between 0 and 15 on the seven-segment display in hex.
The pin-outs for the blue MSP430F16x Lite Development Board are configurable through a programmable PLD. This allows the user to change the pin map in software. You can see the current arrangement of the pins here: LiteBoardPinout
Using the
seg_count()
function you just wrote. Write a program that does the following:
Interrupts, as the name implies, will interrupt a program whenever it is, and when the interrupt is done being serviced it will jump back to wherever it was in the program. This allows the programmer to have more freedom in their code, automates certain functions, and reduces the number of checks handled by the processor.
In order to fire an interrupt, the following must be done:
A typical program using interrupts will look like the following piece of code:
void main(void){
_EINT(); //Enables interrupts globally
//... more code
}
void SOME_interrupt (void) __interrupt[SOME_vector]{
//...more code that runs once interrupt fires
return;
}
Processors are designed to be able to service interrupts from predefined, specific places. The list of possible interrupts is put into an interrupt vector, and each must be enabled individually. To find the name of the interrupt vector that needs to be enabled, check the
MSP430Fx16x.h header file's
Interrupt Vectors
section.
Write an interrupt that will fire when the buttons are pushed. If you need additional help, there are examples in the
../Crossworks MSP430 1.x/samples/
directory.
Modify the program from Problem 1 so that it is interrupt based and does not poll for the buttons being pushed. How does your program behavior changes? When would you want to use polling over using an interrupt?
Notification Switch
Would you like to follow the 'Microcontroller and embedded systems laboratory' conversation and receive update notifications?