i) The Special Function Registers within the 16F1847 microcontroller are held within a number of memory banks. How many memory banks are there within the 16F1847 microcontroller?
ii) Explain two methods to show how a special function register within a particular memory bank can be selected.
The TRIS Registers
The 16F61847A microcontroller has two TRIS registers, TRISA and TRISB, situated in bank 1 in the special function register memory map.
i) What is the function of the TRIS registers?
ii) How can the TRIS registers in bank 1 be accessed?
Write a short program to configure PORTA of the microcontroller as inputs and PORTB of the microcontroller as outputs.
For the remaining exercises assume that PORTA is connected to switches and PORTB is connected to LEDs in common cathode configuration (i.e. output a 1 to illuminate).
Key Press Accumulator
It is required to produce a system incorporating a microcontroller that keeps count (in binary) of the number of times that a key has been pressed. The key is connected to bit RAO of PORTA and when pressed should increment the binary value displayed on LEDs connected to PORTB.
Write a program to meet the above specification, simulate the program to ensure correct operation, program a microcontroller and test.
Software Delays
The 16F 1847 assembly language program listed below is a software time delay incorporating two nested loops.
By incorporating breakpoints and using the stopwatch determine the amount of time elapsed in the software delay assuming the microcontroller is operating from a 4Mhz crystal oscillator. Compare the value obtained above with that obtained by calculation. Are the time values equal?
Travelling LED program
It is required to produce a system incorporating a PIC 16F1847 to produce the following sequence on LEDs (travelling LED).
• 0 0 0 0 0 0 0
0 • 0 0 0 0 0 0
m 0 • 0 0 0 0 0
m 0 0 • 0 0 0 0
0 0 0 0 • 0 0 0
m 0 0 0 0 • 0 0
m 0 0 0 0 0 • 0
m 0 0 0 0 0 0 •
And repeat
The LEDs are connected to PORTB and the sequence should only start after the key connected to RAO has been asserted. Should key RA1 be pressed then all of the LEDs should be switched off The sequence can be set off again by reasserting key RAO. Incorporate a 100ms delay between changes of state of the sequence. Write a program to carry out the above specification, simulate, program a microcontroller and test.