Line: 1 to 1 | |||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Slide 1: Accessing the Real WorldLecture 7 | |||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||
< < | ---++ | ||||||||||||||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||||||||||||||
Writing data to a DACImagine a 12 bit digital to analogue converter with the following register outline: The 12 bit data must be written 4 bits at a time to registers which are selected by the RS bits. The lowest significant digit goes to register 0(both RS bits zero) The medium significant digit to register 1 (RS=01) | |||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||
< < | And the highest significant digit to register 2 (RS=01) | ||||||||||||||||||||||||||||||||||||||||||
> > | And the highest significant digit to register 2 (RS=10) | ||||||||||||||||||||||||||||||||||||||||||
To strobe the data into the register the strobe line must see a low to high transition
The DACWe have a 12 bit DAC, which creates signal levels from 0V to Vcc What is the max. number this DAC can take in decimal and in hex? What is the signal resolution in This is Physics!Preparing data for the DACRemember the bit layout of the DAC register?We must write the
DAC preparationWrite a function which prepares a byte for the DAC The function takes 3 arguments:
What will be the result if you want to write 5 to register to the middle nibble? Solution: DAC preparationNow the test program generating data for the DACStrobeNow create a strobe function which takes DAC data (including the register bits) and generates a strobe signal on the STR line without touching the other bits With a correctly prepared data and register byte this will write the data to the correct register within the DACSolution: StrobeExiting a program gracefullyWhen we have a program like our blink program, then the only way to exit the endless loop is a ^C which will leave the LED in an unknown state. Is there a way to exit the program gracefully and to make sure the LED is always off once the program exits?Yes, there is!Killing the programWhen we kill the program with ^C, a signal (SIGINT) is sent to it which normally results in a brutal stop of the program. It is however possible to capture the signal and do some cleanup before the program finally exits.Signal handlerCatching signals%SLIDESHOWEND% -- Uli Raich - 2017-09-27 CommentsPreparing data for the DAC
|