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!):

  1. 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)
  2. Using ASCII values, write your name in the on-board EEPROM.
  3. Show a snapshot of the EEPROM. Note: If the EEPROM window does not show anything click on LOAD button:

mplab1

  1. Answer the following questions:
    1. 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:

  1. Carefully, read the slides: Chapter 11 / WDT/Clocks / Reset
  2. 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.
  3. 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.
  4. Change the program such that if INT0 is enabled, the program automatically wakes up and stays up for 5 seconds.
  5. Demonstrate that your program operates properly.
  6. Show the flowchart for your program. Bad flowcharts will receive negative 10 points.
  7. Measure the power consumption of the board when it is counting and when it is in sleep mode.
  8. Answer the following questions:
    1. When the processor wakes up, does it continue counting form the previous value or from one (in other words, did the program start over?)
    2. What is your clock speed? How do you know?
    3. What is your Fosc and how do you know.
    4. What is your pre-scaled value?

TEMPERATURE SENSOR:

  1. Carefully read about the Temperature sensor on your demo board. Find it on the board.
  2. 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?
  3. 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.
  4. 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.
  5. Demonstrate that your program operates properly.
  6. Show a snapshot of the EEPROM.
  7. Answer the following questions:
    1. If you recycle the power to the board, will EEPROM still maintain its data (in other words, is EEPROM volatile or non-volatile)?
    2. What is the longest Sleep time we can achieve?

CHANGING BRIGHTNESS/COLORS OF AN LED:

  1. Study and execute the following PWM code. Make sure you understand how it works. Pay attention to how TMR2 and CCP1 are set.
  2. Modify the code such that the brightness of the LED can be changes by changing the potentiometer.
    1. Show two snapshots of the signal when the duty cycle is at its max. and min. value.
    2. Demonstrate the code works properly.
  3. 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.

 

 ---------------------------