Файл: The quintessential PIC microcontroller (S. Katzen, 2000).pdf
ВУЗ: Не указан
Категория: Не указан
Дисциплина: Не указана
Добавлен: 15.06.2025
Просмотров: 5291
Скачиваний: 0
428The Quintessential PIC Microcontroller
14.2A programmer writing an ISR-based handler for an analog module has replaced the retfie instruction in Program 14.2 by return. What e ect will this have?
14.3Real world analog signals are noisy. In practice this means that some form of filtering or smoothing is frequently required. In any circumstance noise coming in from outside should not have any appreciable frequency components above half the sampling rate since such noise will be frequency shifted back into the baseband as shown in Fig. 14.4. Such low-pass filtering must be applied to the signal before the A/D conversion.
Although this external anti-alias filter must by definition be implemented using hardware circuitry (such as a CR network), noise within the passband can be smoothed out using software filtering routines. One simple approach to digital filtering is to take multiple readings and average them to give a composite outcome. For example, 16
readings summed and shifted right four times (÷16) would reduce random noise by a factor of √16 = 4.
Another approach well known to staticians, is to take a moving average; for example, of a stock price over a month interval. An e cient algorithm of this type is a 3-point average:
Array[i] = S4n + Sn2−1 + Sn4−2
where Sn is the nth sample from the analog module.
Show how you could modify the GET_ANALOG subroutine to remember the last samples from the two previous calls and return the smoothed value.
14.4 It has been suggested that as part of the ECG monitor of Example 14.4 that a MAX506 DAC be used to introduce an automatic gain control function preceding the PIC’s analog input. The aim of the AVC is to keep the peak of the analog input between 34 and 78 full scale. How might you go about implementing this subsystem? Hint: Remember that each channel of a MAX506 is the product of its digital input and Vref and that the latter can vary between 0 V and VDD.
14.5How could the time between ECG peaks be measured with a resolution of 10 ms and output at one of the parallel ports as an extension of Example 14.4?
14.6An input analog sinusoid signal, conditioned as shown in Fig. 14.15, is to be full-wave rectified; that is voltages that were originally negative are to have their sign changed. Design a routine to do this assuming that the input voltage is available at ADRES and the processed output is to be presented via Port B to a DAC.
CHAPTER 15
To Have and to Hold
Several midand high-range PIC devices feature a small EEPROM scratchpad memory that can be controlled and accessed indirectly via SpecialPurpose Registers (SPRs) in the same manner as other peripheral devices. An integral non-volatile scratchpad enables the programmer to read and modify static data, such as the odometer tally in a car, which needs to be retained in the absence of a power supply – see Example 12.3 on page 351. Although this facility can be implemented using an external EEPROM memory, such as the 24LC01 of Fig. 12.22 on page 352, where only a modest amount of non-volatile data needs to be stored, integral EEPROM storage increases reliability and reduces cost, size and power requirements.
Our objective here is to examine the non-volatile storage facilities available to members of the mid-range PIC family. After reading this chapter you will:
•Be familiar with the characteristics of the EEPROM Data memory.
•Know how to both read and write data to the EEPROM module.
•Understand how the main flash EEPROM Program memory can be used in some devices to store and retrieve non-volatile data.
•Be able to contrast the EEPROM Data module and flash Program memory as a location for non-volatile data.
The PIC16C83/4 introduced in 1994, was the first PIC device to use EEPROM technology for its main Program store. As we gave seen in Fig. 2.12 on page 27, Electrically Erasable PROM is similar to EPROM but does not require UV radiation to erase data. Although EEPROM technology is more expensive than EPROM, its use in implementing the Program store is convenient in prototyping and educational/hobbyist applications. Along with this innovation, an EEPROM peripheral module was featured which enabled the programmer to store up to 64 bytes of nonvolatile data independently of the normal file register memory.
The PIC16C83/4 and its analogous flash EEPROM memory successor, the PIC16F83/4, remained the only EEPROM family member until the introduction of the PIC16F87X in 1998. As of 2000, Microchip were committed to introduce flash EEPROM versions of most of their standard midand high-range devices. Thus, for example, the PIC16F74 will shadow the PIC16C74 processor.