Download - ORCA
Transcript
triggered the interrupt. As an example, if the interrupt was triggered by the need to send data through the UART, the ISR would send data to the UART‟s transmit buffer. However, the ISR is never manually called, as a normal C function is called. Instead, the ISR is invoked automatically by the PIC24 interrupt hardware on an interrupt occurrence. An ISR is said to execute in the background while the normal program flow executes in the foreground. 4.3.3 Serial peripheral interface The Serial Peripheral Interface (SPI) is a three, or more commonly four wire synchronous serial link, originally developed by Motorola. The SPI is a full duplex communication channel that uses one pin for receiving data one for transmitting, one for the clock and one for selecting a device. The SPI was programmed to have a maximum data rate of 1,250kbps and communicate in 16-bit long packets. The microcontroller in the wireless sensor uses its SPI port to receive data from the external bipolar ADC, as shown in Figure 4.3. Figure 4.3: SPI port linking the ADC to the microcontroller. The SDI2 line is the one transmitting the acquired data to the microcontroller for processing, while the SS2 line forces the ADCs SPI port to „wake up‟ and start transmitting data. The digital clock is transmitted by the microcontroller on the SCK2 line, which is used by the ADC to synchronize the transmission of its data. The CNVST line is used by the microcontroller to force the ADC to sample data and it can also be used to shut down the ADC. Once the sampling of data has taken place, the ADC‟s BUSY line will trigger an interrupt routine in the microcontroller so that it can immediately read the acquired data. 52