Les 6 - onderwerpen

19
Hogeschool Utrecht / Institute for Computer, Communication a nd Media Technology 1 2PROJ5 – PIC assembler 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

description

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. - PowerPoint PPT Presentation

Transcript of Les 6 - onderwerpen

Page 1: Les 6 - onderwerpen

Hogeschool Utrecht / Institute for Computer, Communication and Media Technology

12PROJ5 – PIC assembler

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

Page 2: Les 6 - onderwerpen

Hogeschool Utrecht / Institute for Computer, Communication and Media Technology

22PROJ5 – PIC assembler

Page 3: Les 6 - onderwerpen

Hogeschool Utrecht / Institute for Computer, Communication and Media Technology

32PROJ5 – PIC assembler

PIC - USARTUSART = 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)

Page 4: Les 6 - onderwerpen

Hogeschool Utrecht / Institute for Computer, Communication and Media Technology

42PROJ5 – PIC assembler

PIC - USART

Page 5: Les 6 - onderwerpen

Hogeschool Utrecht / Institute for Computer, Communication and Media Technology

52PROJ5 – PIC assembler

Page 6: Les 6 - onderwerpen

Hogeschool Utrecht / Institute for Computer, Communication and Media Technology

62PROJ5 – PIC assembler

BRGH = 0 BRGH = 1

Page 7: Les 6 - onderwerpen

Hogeschool Utrecht / Institute for Computer, Communication and Media Technology

72PROJ5 – PIC assembler

100- 1 - -R

Page 8: Les 6 - onderwerpen

Hogeschool Utrecht / Institute for Computer, Communication and Media Technology

82PROJ5 – PIC assembler

RR -0101 -

Page 9: Les 6 - onderwerpen

Hogeschool Utrecht / Institute for Computer, Communication and Media Technology

92PROJ5 – PIC assembler

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

Page 10: Les 6 - onderwerpen

Hogeschool Utrecht / Institute for Computer, Communication and Media Technology

102PROJ5 – PIC assembler

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)

Page 11: Les 6 - onderwerpen

Hogeschool Utrecht / Institute for Computer, Communication and Media Technology

112PROJ5 – PIC assembler

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)

Page 12: Les 6 - onderwerpen

Hogeschool Utrecht / Institute for Computer, Communication and Media Technology

122PROJ5 – PIC assembler

power van de 2e USB poort

Page 13: Les 6 - onderwerpen

Hogeschool Utrecht / Institute for Computer, Communication and Media Technology

132PROJ5 – PIC assembler

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

Page 14: Les 6 - onderwerpen

Hogeschool Utrecht / Institute for Computer, Communication and Media Technology

142PROJ5 – PIC assembler

PIC – USART – demo code mainMAIN

CALL UART_INIT

MOVLW 'H'CALL UART_CHAR_SENDMOVLW 'i'CALL UART_CHAR_SENDCALL UART_CLRF_SEND

MAIN_LOOPCALL UART_CHAR_RECEIVESKPC

GOTO MAIN_LOOPMOVWF CharMOVLW '"'CALL UART_CHAR_SENDMOVFW CharCALL UART_CHAR_SENDMOVLW '"'CALL UART_CHAR_SENDCALL UART_CLRF_SENDGOTO MAIN_LOOP

Page 15: Les 6 - onderwerpen

Hogeschool Utrecht / Institute for Computer, Communication and Media Technology

152PROJ5 – PIC assembler

De IR ontvanger (1)

• (alleen) gevoelig voor een ~ 36 kHz signaal.

• Dat signaal mag niet continu zijn

Page 16: Les 6 - onderwerpen

Hogeschool Utrecht / Institute for Computer, Communication and Media Technology

162PROJ5 – PIC assembler

De IR ontvanger (2)

(alleen) gevoelig voor een 36 kHz signaal.

Page 17: Les 6 - onderwerpen

Hogeschool Utrecht / Institute for Computer, Communication and Media Technology

172PROJ5 – PIC assembler

De IR ontvanger (3)

Aanbevolen: puls >= 400uS, periode =< 0.4

Page 18: Les 6 - onderwerpen

Hogeschool Utrecht / Institute for Computer, Communication and Media Technology

182PROJ5 – PIC assembler

De IR ontvanger (4)

Page 19: Les 6 - onderwerpen

Hogeschool Utrecht / Institute for Computer, Communication and Media Technology

192PROJ5 – PIC assembler

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