190 likes | 436 Views
Les 6 - onderwerpen. seriele interface (UART - USB - VCP) IR De datum om je eindopdracht te laten zien is woensdag 8 november, 14:50 .. 17:50. (evt vanaf 13:10) (volgende week mag ook...) Inschrijven in Osiris is verplicht . PIC - USART.
E N D
Les 6 - onderwerpen • seriele interface (UART - USB - VCP) • IR De datum om je eindopdracht te laten zien is woensdag 8 november, 14:50 .. 17:50. (evt vanaf 13:10) (volgende week mag ook...) Inschrijven in Osiris is verplicht Hogeschool Utrecht / Institute for Computer, Communication and Media Technology
Hogeschool Utrecht / Institute for Computer, Communication and Media Technology
PIC - USART USART = Universal Synchronous / Asynchronous Receiver + Transmitter • wij gebruiken asynchroon • PIC UART pins zijn verbonden met een FT232R USB-to-asynchronous converter • Op de PC wordt een (virtuele) seriele poort aangemaakt (XP heeft al een driver) control panel system hardware device manager ports • evt driver van www.ftdichip.com gebruiken • op de PC gebruik je een terminal, bv HyperTerminal (hypertrm, 19k2, no parity, no flow control, hu: com3) Hogeschool Utrecht / Institute for Computer, Communication and Media Technology
PIC - USART Hogeschool Utrecht / Institute for Computer, Communication and Media Technology
Hogeschool Utrecht / Institute for Computer, Communication and Media Technology
BRGH = 0 BRGH = 1 Hogeschool Utrecht / Institute for Computer, Communication and Media Technology
- 0 1 0 - 1 R - Hogeschool Utrecht / Institute for Computer, Communication and Media Technology
1 0 - 1 0 R R - Hogeschool Utrecht / Institute for Computer, Communication and Media Technology
PIC – USART - init make TxD (RC6) output, RxD (RC7) input SPBRG: 19k2 value for high speed TXSTA: 8 bit, enable, asynch, high speed RCSTA: enable, 8 bit, continuous, no ADDEN Hogeschool Utrecht / Institute for Computer, Communication and Media Technology
PIC – USART - send • wacht tot TSR bit aangeeft dat TSR empty is • copy het te verzenden byte naar TXREG • (wacht tot TSR bit aangeeft dat TSR empty is) Hogeschool Utrecht / Institute for Computer, Communication and Media Technology
PIC – USART - receive • als OERR bit gezet is: • clear CREN • wacht een paar instructies • set CREN • als PIR1 : TXIF op 0 gezet is: • lees RCREG, dit is het ontvangen byte (anders is er nog niets ontvangen) Hogeschool Utrecht / Institute for Computer, Communication and Media Technology
power van de 2e USB poort Hogeschool Utrecht / Institute for Computer, Communication and Media Technology
PIC – USART – demo code subroutines UART_INIT : call to inistialise the UART for 19k2 UART_CHAR_SEND : sends the char in W UART_CHAR_RECEIVE : checks the UART for a received char, C flag set when a char is received (char in W), C flag is cleared when no char is received UART_CLRF_SEND : sends the CR LF sequence Hogeschool Utrecht / Institute for Computer, Communication and Media Technology
PIC – USART – demo code main MAIN CALL UART_INIT MOVLW 'H' CALL UART_CHAR_SEND MOVLW 'i' CALL UART_CHAR_SEND CALL UART_CLRF_SEND MAIN_LOOP CALL UART_CHAR_RECEIVE SKPC GOTO MAIN_LOOP MOVWF Char MOVLW '"' CALL UART_CHAR_SEND MOVFW Char CALL UART_CHAR_SEND MOVLW '"' CALL UART_CHAR_SEND CALL UART_CLRF_SEND GOTO MAIN_LOOP Hogeschool Utrecht / Institute for Computer, Communication and Media Technology
De IR ontvanger (1) • (alleen) gevoelig voor een ~ 36 kHz signaal. • Dat signaal mag niet continu zijn Hogeschool Utrecht / Institute for Computer, Communication and Media Technology
De IR ontvanger (2) (alleen) gevoelig voor een 36 kHz signaal. Hogeschool Utrecht / Institute for Computer, Communication and Media Technology
De IR ontvanger (3) Aanbevolen: puls >= 400uS, periode =< 0.4 Hogeschool Utrecht / Institute for Computer, Communication and Media Technology
De IR ontvanger (4) Hogeschool Utrecht / Institute for Computer, Communication and Media Technology
Eenvoudig IR zenden / ontvangen • 36 kHz 28 us per puls 5 * 28 instructies per fase (hoog of laag) • 400 us / 28 us minimaal 14 pulsen, neem bv 30 pulsen • Onmiddelijk daarna de IR ingang lezen (laag == signaal gedetecteerd) • Pauze! • herhaal Hogeschool Utrecht / Institute for Computer, Communication and Media Technology