1 / 19

Microprocessors 2 lesson 7

Microprocessors 2 lesson 7. Subjects lesson 7. Planning Interrupts Serial communication /USART Questions. Interrupt sources. • External Interrupt RA2/INT • TMR0 Overflow Interrupt • PORTA Change Interrupts • 2 Comparator Interrupts • A/D Interrupt • Timer1 Overflow Interrupt

myron
Download Presentation

Microprocessors 2 lesson 7

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Microprocessors 2lesson 7

  2. Subjects lesson 7 • Planning • Interrupts • Serial communication /USART • Questions

  3. Interrupt sources • • External Interrupt RA2/INT • • TMR0 Overflow Interrupt • • PORTA Change Interrupts • • 2 Comparator Interrupts • • A/D Interrupt • • Timer1 Overflow Interrupt • • Timer2 Match Interrupt • • EEPROM Data Write Interrupt • • Fail-Safe Clock Monitor Interrupt • • Enhanced CCP Interrupt

  4. Interrupt Logic

  5. Program memory map

  6. Interrupt Software #include "int16CXX.H" #pragma origin 4 interrupt int_server( void) { int16 var; int_save_registers // W, STATUS (and PCLATH) if (T0IF) { /* TMR0 overflow interrupt */ TMR0 = -255; CharToLed(var); var=var*2; if (var>=255) var=1; T0IF = 0; /* reset flag */ int_restore_registers // W, STATUS (and PCLATH) }

  7. Mainprogram interrupts void main( void) { while (1) { } }

  8. Serial CommunicationIntoduction • Morse codetelegraphy • RS-232 (low-speed, implemented by Serial Ports) • RS485 • Universal Serial Bus (moderate-speed, for connecting computers to peripherals) • FireWire • Fibre Channel (high-speed, for connecting computers to mass storage devices) • InfiniBand (very high speed, broadly comparable in scope to PCI) • Serial Attached SCSI • Serial ATA • PCI Express

  9. Serial Communication RS232-C 1 • Half duplex • Full duplex • 5,6,7,8 databits • ASCII (0-127) • Stop bit(s) • Parity • DCE (Data communication equipment) • DTE(Data terminal Equipment (PC))

  10. 9 Pin Connector on a DTE device (PC connection) Male RS232 DB9 Pin Number Direction of signal: 1 Carrier Detect (CD) (from DCE) Incoming signal from a modem 2 Received Data (RD) Incoming Data from a DCE 3 Transmitted Data (TD) Outgoing Data to a DCE 4 Data Terminal Ready (DTR) Outgoing handshaking signal 5 Signal Ground Common reference voltage 6 Data Set Ready (DSR) Incoming handshaking signal 7 Request To Send (RTS) Outgoing flow control signal 8 Clear To Send (CTS) Incoming flow control signal 9 Ring Indicator (RI) (from DCE) Incoming signal from a modem RS232DB9-connector

  11. Serial Communication RS232SynchroneA-Synchrone • Synchrone: • Always dataflow of bits to synchronisize • A-Synchrone; • When no data needed to send no dataflow. Synchronysation by start and stop bits (So slower)

  12. RS232 Level Transmitter (V) Receiver (V) Space status (0) +5 ... +15 +3 ... +25 Mark status (1) -5 ... -15 -3 ... -25 Not defined - -3 .. -3 …+3 . +3 Serial Communication RS232Voltages

  13. RS232 kabellengte volgens Texas Instruments Baud rate Maximum cabellength(m) 19200 15 9600 150 4800 300 2400 900 Serial Communication Cabellenght versus baudrate

  14. • Asynchronous - Auto-wake-up - Auto baud calibration - 13-bit Break character • Synchronous – selectable clock • Synchronous – clock polarity Serial Communication Serial communication PIC16F688

  15. bit 7CSRC: Clock Source Select bit Asynchronous mode: Don’t care Synchronous mode: 1 = Master mode (clock generated internally from BRG) 0 = Slave mode (clock from external source) bit 6TX9: 9-bit Transmit Enable bit 1 = Selects 9-bit transmission 0 = Selects 8-bit transmission bit 5TXEN: Transmit Enable bit 1 = Transmit enabled 0 = Transmit disabled Note: SREN/CREN overrides TXEN in Sync mode. bit 4SYNC: USART Mode Select bit 1 = Synchronous mode 0 = Asynchronous mode bit 3SENDB: Send Break Character bit Asynchronous mode: 1 = Send Sync Break on next transmission (cleared by hardware upon completion) 0 = Sync Break transmission completed Synchronous mode: Don’t care bit 2BRGH: High Baud Rate Select bit Asynchronous mode: 1 = High speed 0 = Low speed Synchronous mode: Unused in this mode bit 1TRMT: Transmit Shift Register Status bit 1 = TSR empty 0 = TSR full bit 0 TX9D: 9th bit of Transmit Data Can be address/data bit or a parity bit. Transmit status+control register

  16. Buad ratecontrol

  17. Baud ratecalculating

  18. SETUPfor serialcommunication

  19. Serial Communication Exercise • In the last week of this quarter you have to finish a programm what shows the working of the serial port. You can do this with 2 persons. • The programm on the 2 boards has to send the measured value from AN0 analogue input to the other board. The value received from the other board has to be shown , binary, on the 8 leds

More Related