Copying Data into On-Board EEPROM/Watchdog & Sleep Mode/Temperature Sensor
________________________Updated
04/03/2019 _________________________________
ALL SECTIONS MUST BE DEMONSTRATED IN CLASS -
OTHERWISE NO GRADE WILL BE RECEIVED! YOU MUST BE BLE TO ANSWER ALL THE EQUESTIONS!
YOU MUST DO THESE PROJECTS INDIVIDUALLY. Make sure the MAIN part of the program is very
clear and simple. Use subroutines for each main task! Programs with no subroutines will not receive full credit! If you are not sure about a
design requirement, make sure you check with me or other students!
ON-BOARD EEPROM (for practice only - it will help you complete other parts!):
- Run this C program (zipfile) and observe how you can write data into the on-board 256-byte EEPROM in the PIC18F46K20 (This is the type of results you should see)
- Using ASCII values, write your name in the on-board EEPROM.
- Show a snapshot of the EEPROM. Note: If the EEPROM window does not show anything click on LOAD button:
- Answer the following questions:
- If you recycle the power to the board, will EEPROM still maintain its data (in other words, is EEPROM volatile or non-volatile)?
WATCHDOG & SLEEP MODE:
- Carefully, read the slides: Chapter 11 /
WDT/Clocks / Reset
- Write a program such that it counts for EXACTLY 5 seconds (1,2,3,....); each count can represent one second. The count values must be somehow displayed. You must use TMR0 to generate the timing signal. The Fosc can be selected anyway you like.
- Force the program to go to sleep after 5 seconds. The program must remain in sleep for 10 seconds and then it must wake up.
- Change the program such that if INT0 is enabled, the program automatically wakes up and stays up for 5 seconds.
- Demonstrate that your program operates properly.
- Show the flowchart for your program. Bad flowcharts will receive negative 10 points.
- Measure the power consumption of the board when it is counting and when it is in sleep mode.
- Answer the following questions:
- When the processor wakes up, does it continue counting form the previous value or from one (in other words, did the program start over?)
- What is your clock speed? How do you know?
- What is your Fosc and how do you know.
- What is your pre-scaled value?
TEMPERATURE SENSOR:
- Carefully read about the Temperature sensor on your demo board. Find it on the board.
- Examine the ADC C code and make sure you understand how TIMER0 and ADC is configured. Check how LEFT2RIGHT and RIGHT2LEFT variabes are defined. What is BOOL?
- Write a program such that it measures the temperature every 5 seconds. Each measured value must be recorded in the on-board EEPROM. Following each measurement the program must go to sleep. The measured temperate must be displayed on the LCD.
- If the user enables INT0, the processor must wake up immediately and stays up for 5 seconds. It should measure the temperature, and save the value in the on-board EEPROM.
- Demonstrate that your program operates properly.
- Show a snapshot of the EEPROM.
- Answer the following questions:
- If you recycle the power to the board, will EEPROM still maintain its data (in other words, is EEPROM volatile or non-volatile)?
- What is the longest Sleep time we can achieve?
CHANGING BRIGHTNESS/COLORS OF AN LED:
- Study and execute the following PWM code. Make sure you understand how it works. Pay attention to how TMR2 and CCP1 are set.
- Modify the code such that the brightness of the LED can be changes by changing the potentiometer.
- Show two snapshots of the signal when the duty cycle is at its max. and min. value.
- Demonstrate the code works properly.
- EXTRA CREDIT: Connect one (or two) 3-pin Red/Green
LEDs to your board and make the colors change randomly! You can design
many interesting color patterns. Learn more... If you don't have the LED, just use the scope.
---------------------------