In this learning module, you'll build a system that converts the voltage over a potentiometer into an 8-bit integer and then displays this integer on the LCD display. The complete hardware schematic for this system is already shown in figure 30. So we only have left to discuss the software side of this project.
A listing of the program you'll be using is found below.
#include "kernel.c" void main(void){ unsigned int ddata; int i; int ivalue; init(); /*initialize LCD display*/ OutChar(254);OutChar(1); while(1){ /*begin conversion*/ clear_pin(1); pause(1000); /*shift data in */ ddata=shiftin(SPI_62kHz); ddata &= ~0x80; //zeros the msb OutChar(254);OutChar(2); OutString("S= "); OutUDec(ddata);OutChar(SP);OutChar(SP);OutChar(SP); } } #include "vectors.c"This program is rather simple due to the functionality inherent in the SPI/SCI subsystems. The
kernel.c
used in this module will be found in the attached appendix.