<< Chapter < Page | Chapter >> Page > |
#include "msp430x20x3.h"
void main(void)
{
WDTCTL |= WDTPW + WDTHOLD;
DCOCTL = CALDCO_8MHZ;
BCSCTL1 = CALBC1_8MHZ;
P1DIR |= 0x01;
SD16CTL |= SD16REFON + SD16SSEL_1;
SD16INCTL0 |= SD16INCH_6;
SD16CCTL0 |= SD16SC;
while (1) {
while ((SD16IV & SD16IFG)==0);
if (SD16MEM6 >= 0xD6D8)
P1OUT |= 0x01;
else
P1OUT &= ~0x01;
_NOP();
}
}
_NOP()
after a sample is taken from the ADC, the user may check the
SD16MEMx
register (by setting a breakpoint at the _NOP() command) to see the new value that has been stored. If a value has changed since the last time the processor was halted, it will turn red in the watch window.Add the file containing the LED dimmer function you wrote in Lab 4 to a new project in which you configure the SD Converter. Attach a Photo Diode (DigiKey# ********), a diode that outputs a voltage depending on the ammount of light that hits it, to any one of the SD16 inputs. Input the SD16MEMx value into the LED dimmer function in such a way that the LED's brigtness is indirectly propotional to the ammount of light that hits the Photo Diode. In other words, if we block the light to the diode, the LED should appear brighter; if we shine light on the diode, the LED should appear dimmer. If you do not have access to a Photo Diode, simply set the input to the integrated temperature sensor and perform the same exercise.
Now, chose any analog source (temperature sensor, Photo Diode, function generator etc.) on any input channel and store the values in flash using what you learned in
Lab 6 . After a specific number (that you select) of samples are stored, have your program output the values using the
printf
with the help of a
for
or
while
loop. Then take the values and plot them on a graph. You may want to store every 10th (or 20th or 50th etc.) sample in flash to be able to see the analog signal over a longer period of time.
Notification Switch
Would you like to follow the 'Introduction to the texas instruments ez430' conversation and receive update notifications?