MPASM 5.46 AT89C2051_PROGRAMMER.ASM :21:50 PAGE 1 VALUE

Size: px
Start display at page:

Download "MPASM 5.46 AT89C2051_PROGRAMMER.ASM :21:50 PAGE 1 VALUE"

Transcription

1 MPASM 5.46 AT89C2051_PROGRAMMER.ASM :21:50 PAGE LIST N= ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; _ ; / \ ( _ )/ _ \ / \ / _ \ / ; / _ \ / _ \ (_) ) \ ; / \ (_) \, / / _ ) ; /_/ \_\_ \ / /_/ \ \ / / _ ; ; ; _ \ ; _) ' / _ \ / _` ' / _` '_ ` _ \ '_ ` _ \ / _ \ ' ; / (_) (_ (_ / ; _ _ \ / \, _ \,_ _ _ _ _ _ _ \ _ ; / ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; Copyright (C) 2013 VICTOR MOISEY ; Permission is granted to copy, distribute and/or modify this document ; under the terms of the GNU Free Documentation License, Version ; or any later version published by the Free Software Foundation; ; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts ; A copy of the license is included in the section entitled "GNU ; Free Documentation License" ; ; ; ; ; ; TITLE ""

2 MPASM 5.46 AT89C2051_PROGRAMMER.ASM :21:50 PAGE PAGE

3 MPASM 5.46 AT89C2051_PROGRAMMER.ASM :21:50 PAGE PAGE #INCLUDE P16F877.INC LIST ;========================================================================== ; MPASM PIC16F877 processor include ; ; (c) Copyright Microchip Technology, All rights reserved ;========================================================================== LIST F CONFIG _XT_OSC&_WDT_OFF&_PWRTE_ON&_LVP_OFF IDLOCS 0051 ; 33H ; ; PIN NAME DESIGNATION DISCRIPTION ; ; 2 RA0/AN0 PRESS SWITCH DIGITAL INPUT ; 3 RA1/AN1 NOT USED DIGITAL OUTPUT ; 4 RA2/AN2/Vref- NOT USED DIGITAL OUTPUT ; 5 RA3/AN3/Vref+ NOT USED DIGITAL OUTPUT ; 6 RA4/T0CKI NOT USED DIGITAL OUTPUT ; 7 RA5/AN4/SS NOT USED DIGITAL OUTPUT ; ; 33 RB0/INT DATA IN/OUT DIGITAL I/O PULLED UP ; 34 RB1 DATA IN/OUT DIGITAL I/O PULLED UP ; 35 RB2 DATA IN/OUT DIGITAL I/O PULLED UP ; 36 RB3/PGM DATA IN/OUT DIGITAL I/O PULLED UP ; 37 RB4 DATA IN/OUT DIGITAL I/O PULLED UP ; 38 RB5 DATA IN/OUT DIGITAL I/O PULLED UP ; 39 RB6/PGC DATA IN/OUT DIGITAL I/O PULLED UP ; 40 RB7/PGD DATA IN/OUT DIGITAL I/O PULLED UP ; ; 15 RC0/T1OSO/T1CK1 RED DIGITAL OUTPUT ; 16 RC1/T1OSI/CCP2 GREEN DIGITAL OUTPUT ; 17 RC2/CCP1 BLUE DIGITAL OUTPUT ; 18 RC3/SCK/SCL NOT USED DIGITAL OUTPUT ; 23 RC4/SDI/SDA CTS DIGITAL OUTPUT ; 24 RC5/SDO RTS DIGITAL INPUT ; 25 RC6/TX/CK TX SERIAL OUTPUT ; 26 RC7/RX/DT RX SERIAL INPUT ; ; 19 RD0/PSP0 XTAL1 DIGITAL OUTPUT ; 20 RD1/PSP1 PROG DIGITAL OUTPUT ; 21 RD2/PSP2 P_33 DIGITAL OUTPUT ; 22 RD3/PSP3 P_34 DIGITAL OUTPUT ; 27 RD4/PSP4 P_35 DIGITAL OUTPUT ; 28 RD5/PSP5 VCC_OFF DIGITAL OUTPUT ; 29 RD6/PSP6 VPP_OFF DIGITAL OUTPUT ; 30 RD7/PSP7 _12V_5V DIGITAL OUTPUT ; ; 8 RE0/RD/AN5 NOT USED DIGITAL OUTPUT ; 9 RE1/WR/AN6 NOT USED DIGITAL OUTPUT ; 10 RE2/CS/AN7 NOT USED DIGITAL OUTPUT ; ; 12 VSS1-0V ; 31 VSS2-0V ; 11 VDD1 - +5V ; 32 VDD2 - +5V ; ; 1 MCLR/Vpp/THV ; 13 OSC1/CLKIN ; 14 OSC2/CLKOUT ; ' ' ' ' ' ; ; CRYSTAL FREQUENCY = Hertz ; CYCLE TIME = Hertz/1,085 micro seconds ;

4 MPASM 5.46 AT89C2051_PROGRAMMER.ASM :21:50 PAGE PAGE #DEFINE _Z STATUS,Z #DEFINE _C STATUS,C #DEFINE _DC STATUS,DC #DEFINE _RP0 STATUS,RP #DEFINE RED PORTC,0 ; PROGRAMMER STATUS LED #DEFINE GREEN PORTC,1 ; PROGRAMMER STATUS LED #DEFINE BLUE PORTC,2 ; PROGRAMMER STATUS LED #DEFINE PROG PORTD, #DEFINE _12V_5V PORTD,7 ; 0=+12V, 1=+5V #DEFINE XTAL1 PORTD, #DEFINE VPP_OFF PORTD,6 ; 0=VPP, 1=VPP OFF #DEFINE RTS PORTC,5 ; SERIAL PORT CONTROL #DEFINE CTS PORTC,4 ; SERIAL PORT CONTROL #DEFINE BUFFER_FLAG CONTROL, #DEFINE PRESS_SWITCH PORTA, #DEFINE BYTE_FLAG CONTROL, #DEFINE BYTE_ERROR CONTROL, #DEFINE ADDRESS_DIFFERENCE CONTROL, ; ; PORT C ; _12V_5V VPP_OFF VCC_OFF P_35 P_34 P_33 PROG XTAL SIGNATURE_MODE EQU 000H ; READ_MODE EQU 010H ; WRITE_MODE EQU 018H ; ERASE_MODE EQU 004H ; C LOCK_MODE_1 EQU 01CH ; C LOCK_MODE_2 EQU 00CH ; C STEP_1 EQU 0C0H ; STEP_2 EQU 082H ; ; CBLOCK 20H SERIAL_BYTE BYTE_COUNT_HI BYTE_COUNT_LO D D D HEX_ BYTE_COUNT SERIAL_BUFFER_COUNTER ADDRESS_HI A ADDRESS_LO B SERIAL_BUFFER: B THIRTY_SEC_DELAY C CONTROL D BUFFER_BYTE E HEX_COUNTER F SIGNATURE_BYTE_COUNTER SIGNATURE_BYTE_0: OFFSET TABLE_POINTER COLUMN_COUNTER ASCII_CHAR_HI ASCII_CHAR_LO MASTER_ADDR_LO MASTER_ADDR_HI A MODE ENDC ; BANK0 LIMIT: 7FH ;

5 MPASM 5.46 AT89C2051_PROGRAMMER.ASM :21:50 PAGE PAGE ORG CLRF PORTA CLRF PORTB CLRF PORTC CLRF PORTD CLRF PORTE BSF _RP0 ; BANK MOVLW MOVWF TRISA ; RA5 TO RA1 - DIGITAL OUTPUTS ; RA0 - DIGITAL INPUT CLRF TRISB ; PORTB ALL OUTPUTS CLRF TRISD ; ALL PINS DIGITAL OUTPUTS. 000A CLRF TRISE ; RE0 TO RE2 - DIGITAL OUTPUTS. 000B 30E MOVLW 0E0H ; RC7 TO RC5 - DIGITAL INPUT, RC4 TO RC0 - DIGITAL OUTPUT. 000C MOVWF TRISC 000D MOVLW 6 ; RA0-RA3, RA5, RE0-RE2 DIGITAL I/O. 000E 009F MOVWF ADCON F BCF _RP0 ; BANK BC CLRF CONTROL BSF CTS CALL POWER_DOWN A CLRF SERIAL_BUFFER_COUNTER MOVLW 011H ; TIMER1-1:2 PRESCALE, OSCILLATOR IS SHUT OFF, INTERNAL ; CLOCK, TIMER 1 ON MOVWF T1CON BSF _RP0 ; BANK MOVLW 23 ; 3,6864MHz CLOCK, 9600B/s, BRGH= MOVWF SPBRG BSF TXSTA,BRGH ; BAUD RATE SELECT BIT - HIGH SPEED. 001A BCF _RP0 ; BANK B BSF RCSTA,SPEN ; ENABLE SYNCHRONOUS SERIAL PORT. 001C BSF RCSTA,CREN ; ENABLE RECEPTION D BSF _RP0 ; BANK E BSF TXSTA,TXEN ; ENABLE TRANSMISSION F MOVLW 57H ; PORTB WEAK PULLUPS ; INTEG - NO INFO IN MANUAL FOR THIS ; T0CS, INTERNAL INSRTUCTION CYCLE CLOCK ; T0SE, NOT RELEVANT ; PSA, ASSIGNED TO TIMER0 MODULE ; PS2:PS0, 1: MOVWF OPTION_REG L2340: BCF _RP0 ; BANK CALL LF B CALL DRAW_LINE CALL SIGN_ON A CALL CONFIGURATION B CALL DRAW_LINE CALL LF ; MENU_LOOP: CALL MENU MENU_LOOP_10: A CALL GREEN_ON 002A 23A CALL SOCKET_DEVICE 002B CALL LF 002C 303E MOVLW ">" 002D 00A MOVWF SERIAL_BYTE 002E 235A CALL SERIAL_OUT 002F BCF CTS ; ALLOW BYTE FROM CONSOLE CALL SERIAL_IN ; FETCH MENU BYTE BSF CTS ; NO MORE BYTES FOR NOW B MOVLW 07BH ; CONVERT LOWER CASE a-z TO UPPER CASE A-Z SUBWF SERIAL_BYTE,W BTFSC _C B GOTO $+6 ; SERIAL IN IS GREATER THAN a-z WINDOW F MOVLW ; SERIAL IN IS WITHIN THE a-z WINDOW ADDWF SERIAL_BYTE,W C BTFSS _C B GOTO $+2 ; SERIAL IN IS LESS THAN THE a-z WINDOW. 003A 12A BCF SERIAL_BYTE,5 ; CHANGE LOWER CASE TO UPPER CASE B 300D MOVLW 0DH ; CHANGE CARRIAGE RETURN TO AN "M" 003C XORWF SERIAL_BYTE,W 003D 1D BTFSS _Z 003E GOTO $+3

6 MPASM 5.46 AT89C2051_PROGRAMMER.ASM :21:50 PAGE 6 003F 304D MOVLW "M" A MOVWF SERIAL_BYTE A CALL SERIAL_OUT CALL LF MOVLW "9" ; TEST FOR BINARY PROGRAM MODE XORWF SERIAL_BYTE,W BTFSC _Z GOTO BINARY_PROGRAM MOVLW "4" ; TEST FOR BINARY VERIFY MODE XORWF SERIAL_BYTE,W BTFSC _Z 004A 208E CALL BINARY_VERIFY B MOVLW "2" ; TEST FOR READ DEVICE BINARY MODE. 004C XORWF SERIAL_BYTE,W 004D BTFSC _Z 004E 298F GOTO READ_DEVICE_BINARY F MOVLW "7" ; TEST FOR LOCK BITS MODE XORWF SERIAL_BYTE,W BTFSC _Z FC GOTO LOCK_BITS MOVLW "8" ; TEST FOR HEX PROGRAM MODE XORWF SERIAL_BYTE,W BTFSC _Z D GOTO HEX_PROGRAM MOVLW "5" ; TEST FOR SIGNATURE MODE XORWF SERIAL_BYTE,W BTFSC _Z 005A 29CC GOTO READ_SIGNATURE_BYTES B 304D MOVLW "M" ; TEST FOR MENU. 005C XORWF SERIAL_BYTE,W 005D BTFSC _Z 005E GOTO MENU_LOOP F MOVLW "1" ; TEST FOR READ DEVICE HEX XORWF SERIAL_BYTE,W BTFSC _Z A CALL READ_DEVICE_HEX MOVLW "3" ; TEST FOR HEX VERIFY XORWF SERIAL_BYTE,W BTFSC _Z CALL HEX_VERIFY MOVLW "6" ; TEST FOR BLANK CHECK XORWF SERIAL_BYTE,W BTFSC _Z 006A 28A GOTO BLANK_CHECK B MOVLW "0" ; TEST FOR ERASE. 006C XORWF SERIAL_BYTE,W 006D BTFSC _Z 006E 28BF GOTO ERASE_DEVICE F GOTO MENU_LOOP_ ; BINARY_PROGRAM: CALL RED_ON F CALL SEND_BINARY_FILE CALL FILE_INPUT_DELAY B CALL CHIP_ERASE ; ERASE DEVICE AND SET ALL PINS TO ZERO B CALL PROGRAMMING F CALL START_TIMER_ MOVLW WRITE_MODE CALL SET_MODE L2457: CALL FETCH_BYTE ; FETCH BYTE FROM BUFFER C3C BTFSS BUFFER_FLAG ; TEST FOR BYTE VALIDITY. 007A 288A GOTO L2520 ; NO BYTE AVAILABLE. 007B 30FF MOVLW 0FFH ; FF'S ARE NOT PROGRAMMED. 007C 063D XORWF BUFFER_BYTE,W 007D BTFSC _Z 007E GOTO L F 083D MOVF BUFFER_BYTE,W ; TRANSFER BYTE TO AT89C MOVWF PORTB CALL DELAY_500US BCF PROG ; PROGRAMMING PULSE GOTO $ GOTO $+1

7 MPASM 5.46 AT89C2051_PROGRAMMER.ASM :21:50 PAGE BSF PROG CALL WAIT_PROG ; 2ms DELAY FOR PROGRAMMING CYCLE TO FINISH L2470: A CALL INCREMENT_ADDRESS_COUNTER A CALL TOGGLE_RED GOTO L A L2520: 008A CALL POWER_DOWN 008B CLRF T2CON ; STOP TIMER C 237D CALL PROGRAMMING_COMPLETE 008D GOTO MENU_LOOP_ ; E BINARY_VERIFY: E 22CB CALL BLUE_ON F 237F CALL SEND_BINARY_FILE CALL FILE_INPUT_DELAY CALL VERIFYING F CALL START_TIMER_ MOVLW READ_MODE CALL SET_MODE L2840: CALL FETCH_BYTE ; FETCH BYTE FROM BUFFER C3C BTFSS BUFFER_FLAG ; TEST FOR BYTE VALIDITY F GOTO L2850 ; VALID BYTE NOT AVAILABLE, END OF FILE MOVF PORTB,W ; READ BYTE FROM DEVICE D XORWF BUFFER_BYTE,W 009A 1D BTFSS _Z 009B 28A GOTO L2860 ; VERIFY ERROR C 232A CALL INCREMENT_ADDRESS_COUNTER D CALL TOGGLE_BLUE E GOTO L F L2850: 009F CALL VERIFY_SUCCESSFUL 00A CALL POWER_DOWN 00A GOTO MENU_LOOP_10 00A L2860: 00A CALL POWER_DOWN 00A CLRF T2CON ; STOP TIMER 2. 00A CALL EMPTY_BUFFER 00A CALL VERIFY_ERROR 00A GOTO MENU_LOOP_ ; A BLANK_CHECK: A7 22CB CALL BLUE_ON A MOVLW READ_MODE 00A CALL SET_MODE AA BSF _12V_5V ; VPP IS SET TO 5V. 00AB BCF VPP_OFF ; VPP IS SWITCHED ON. 00AC 22DA CALL DELAY_10MS AD MOVLW 8 00AE 00A MOVWF BYTE_COUNT_HI 00AF L2740: 00AF 01A CLRF BYTE_COUNT_LO 00B L2750: 00B MOVF PORTB,W 00B1 3AFF XORLW 0FFH 00B2 1D BTFSS _Z 00B3 28BC GOTO L2760 ; DEVICE NOT BLANK. 00B4 232A CALL INCREMENT_ADDRESS_COUNTER B5 0BA DECFSZ BYTE_COUNT_LO,F 00B6 28B GOTO L B7 0BA DECFSZ BYTE_COUNT_HI,F 00B8 28AF GOTO L B CALL POWER_DOWN 00BA CALL DEVICE_BLANK 00BB GOTO MENU_LOOP_10 00BC L2760: 00BC CALL POWER_DOWN 00BD CALL DEVICE_NOT_BLANK 00BE GOTO MENU_LOOP_ ; BF ERASE_DEVICE:

8 MPASM 5.46 AT89C2051_PROGRAMMER.ASM :21:50 PAGE 8 00BF 23A CALL PRESS_0 00C BCF CTS 00C CALL SERIAL_IN 00C BSF CTS 00C MOVLW "0" 00C XORWF SERIAL_BYTE,W 00C5 1D BTFSS _Z 00C6 28D GOTO $+11 00C7 23A CALL PRESS_STAR 00C BCF CTS 00C CALL SERIAL_IN 00CA BSF CTS 00CB 302A MOVLW "*" 00CC XORWF SERIAL_BYTE,W 00CD 1D BTFSS _Z 00CE 28D GOTO $+3 00CF 222B CALL CHIP_ERASE 00D GOTO MENU_LOOP_10 00D1 23A CALL DEVICE_NOT_ERASED 00D GOTO MENU_LOOP_ ; D HEX_PROGRAM: D CALL RED_ON ; RED LED INDICATES PROGRAMMING MODE D CALL SEND_HEX_FILE ; PROMPT USER D CALL FILE_INPUT_DELAY ; WAIT FOR FILE TO BE SENT D6 222B CALL CHIP_ERASE ; ERASE DEVICE AND SET ALL SOCKET PINS TO ZERO D7 237B CALL PROGRAMMING ; INFORM USER D8 235F CALL START_TIMER_2 ; FLASH RED LED WHILE PROGRAMMING D9 01C CLRF MASTER_ADDR_LO ; KEEP TRACK OF INPUT BYTE ADDRESSES. 00DA 01C CLRF MASTER_ADDR_HI DB MOVLW WRITE_MODE 00DC CALL SET_MODE DD L2560: 00DD CALL FETCH_BYTE ; WAIT FOR COLON. 00DE 1C3C BTFSS BUFFER_FLAG ; MAKE SURE THERE IA A VALID BYTE. 00DF 292C GOTO L2730 ; INVALID BYTE. 00E0 303A MOVLW ":" 00E1 063D XORWF BUFFER_BYTE,W 00E2 1D BTFSS _Z ; COLON FOUND. 00E3 28DD GOTO $-6 ; NOT COLON, TRY ANOTHER BYTE. 00E CALL GET_HEX_BYTE 00E5 193C BTFSC BYTE_ERROR 00E6 292C GOTO L E MOVF HEX_,W ; BYTE VALID, RECORD LENGTH, TEST FOR ZERO. 00E BTFSC _Z 00E9 291C GOTO L2580 ; RECORD LENGTH=0. 00EA 00BE MOVWF HEX_COUNTER 00EB CALL GET_HEX_BYTE ; FETCH MSB OF DATA ADDRESS. 00EC 193C BTFSC BYTE_ERROR 00ED 292C GOTO L2730 ; INPUT BYTE ERROR. 00EE MOVF HEX_,W 00EF 00A MOVWF ADDRESS_HI 00F CALL GET_HEX_BYTE ; FETCH LSB OF DATA ADDRESS. 00F1 193C BTFSC BYTE_ERROR 00F2 292C GOTO L2730 ; INPUT BYTE ERROR. 00F MOVF HEX_,W 00F4 00AA MOVWF ADDRESS_LO 00F CALL GET_HEX_BYTE ; RECORD TYPE. DO NOTHING WITH THIS. 00F6 193C BTFSC BYTE_ERROR 00F7 292C GOTO L F L2690: 00F CALL GET_HEX_BYTE ; FETCH DATA BYTE. 00F9 193C BTFSC BYTE_ERROR 00FA 292C GOTO L2730 ; BYTE ERROR. 00FB L2695: 00FB 082A MOVF ADDRESS_LO,W ; COMPARE MASTER AND INPUT ADDRESSES. 00FC XORWF MASTER_ADDR_LO,W 00FD 1D BTFSS _Z 00FE GOTO L2735 ; ADDRESSES DIFFERENT. 00FF MOVF ADDRESS_HI,W XORWF MASTER_ADDR_HI,W D BTFSS _Z GOTO L2735 ; ADDRESSES DIFFERENT BC BCF ADDRESS_DIFFERENCE ; INDICATE DIFFERENCE FF MOVLW 0FFH ; FF'S ARE NOT PROGRAMMED XORWF HEX_,W BTFSC _Z GOTO L MOVF HEX_,W ; TRANSFER BYTE TO AT89C MOVWF PORTB 010A CALL DELAY_500US 010B BCF PROG ; PROGRAMMING PULSE. 010C 290D GOTO $+1 ; TWO MACHINE CYCLES. 010D 290E GOTO $+1

9 MPASM 5.46 AT89C2051_PROGRAMMER.ASM :21:50 PAGE 9 010E BSF PROG 010F CALL WAIT_PROG ; 2ms DELAY FOR PROGRAMMING CYCLE TO FINISH L2700: A CALL INCREMENT_ADDRESS_COUNTER F CALL INCREMENT_MASTER_ADDRESS BC BTFSC ADDRESS_DIFFERENCE FB GOTO L A CALL TOGGLE_RED CALL INCREMENT_ADDRESS ; INCREMENT RECORD ADDRESS BBE DECFSZ HEX_COUNTER,F ; COUNT BYTES IN RECORD F GOTO L CALL GET_HEX_BYTE ; READ CHECKSUM C BTFSC BYTE_ERROR 011A 292C GOTO L2730 ; BYTE ERROR. 011B 28DD GOTO L2560 ; READ ANOTHER RECORD. 011C L2580: 011C CALL GET_HEX_BYTE ; READ ADDRESS HIGH. 011D 193C BTFSC BYTE_ERROR 011E 292C GOTO L2730 ; INPUT BYTE ERROR. 011F CALL GET_HEX_BYTE ; READ ADDRESS LOW C BTFSC BYTE_ERROR C GOTO L2730 ; INPUT BYTE ERROR CALL GET_HEX_BYTE ; READ RECORD TYPE C BTFSC BYTE_ERROR C GOTO L2730 ; INPUT BYTE ERROR CALL GET_HEX_BYTE ; READ CHECKSUM C BTFSC BYTE_ERROR C GOTO L2730 ; INPUT BYTE ERROR CALL POWER_DOWN CLRF T2CON 012A 237D CALL PROGRAMMING_COMPLETE 012B GOTO MENU_LOOP_10 012C L2730: 012C CALL POWER_DOWN 012D CLRF T2CON ; STOP TIMER E CALL EMPTY_BUFFER 012F CALL INPUT_BYTE_ERROR GOTO MENU_LOOP_ L2735: BC BSF ADDRESS_DIFFERENCE GOTO L ; HEX_VERIFY: CB CALL BLUE_ON CALL SEND_HEX_FILE CALL FILE_INPUT_DELAY CALL VERIFYING F CALL START_TIMER_ C CLRF MASTER_ADDR_LO ; KEEP TRACK OF INPUT BYTE ADDRESSES C CLRF MASTER_ADDR_HI A MOVLW READ_MODE 013B CALL SET_MODE 013C L2790: 013C CALL FETCH_BYTE ; WAIT FOR COLON. 013D 1C3C BTFSS BUFFER_FLAG ; MAKE SURE THERE IA A VALID BYTE. 013E GOTO L2820 ; INVALID BYTE. 013F 303A MOVLW ":" D XORWF BUFFER_BYTE,W D BTFSS _Z C GOTO $ CALL GET_HEX_BYTE C BTFSC BYTE_ERROR GOTO L MOVF HEX_,W ; BYTE VALID, RECORD LENGTH, TEST FOR ZERO BTFSC _Z GOTO L2810 ; RECORD LENGTH= BE MOVWF HEX_COUNTER A CALL GET_HEX_BYTE ; FETCH MSB OF DATA ADDRESS. 014B 193C BTFSC BYTE_ERROR 014C GOTO L2820 ; INPUT BYTE ERROR. 014D MOVF HEX_,W 014E 00A MOVWF ADDRESS_HI F CALL GET_HEX_BYTE ; FETCH LSB OF DATA ADDRESS C BTFSC BYTE_ERROR GOTO L2820 ; INPUT BYTE ERROR MOVF HEX_,W AA MOVWF ADDRESS_LO CALL GET_HEX_BYTE ; RECORD TYPE. DO NOTHING WITH THIS C BTFSC BYTE_ERROR GOTO L L2800:

10 MPASM 5.46 AT89C2051_PROGRAMMER.ASM :21:50 PAGE CALL GET_HEX_BYTE ; FETCH DATA BYTE C BTFSC BYTE_ERROR GOTO L2820 ; BYTE ERROR. 015A L2805: 015A 082A MOVF ADDRESS_LO,W ; COMPARE MASTER AND INPUT ADDRESSES. 015B XORWF MASTER_ADDR_LO,W 015C 1D BTFSS _Z 015D 298D GOTO L2835 ; ADDRESSES DIFFERENT E MOVF ADDRESS_HI,W 015F XORWF MASTER_ADDR_HI,W D BTFSS _Z D GOTO L2835 ; ADDRESSES DIFFERENT BC BCF ADDRESS_DIFFERENCE ; ADDRESSES ARE THE SAME MOVF PORTB,W XORWF HEX_,W D BTFSS _Z GOTO L2830 ; VERIFY ERROR L2808: A CALL INCREMENT_ADDRESS_COUNTER F CALL INCREMENT_MASTER_ADDRESS BC BTFSC ADDRESS_DIFFERENCE 016A 295A GOTO L B CALL TOGGLE_BLUE C CALL INCREMENT_ADDRESS ; INCREMENT RECORD ADDRESS. 016D 0BBE DECFSZ HEX_COUNTER,F ; COUNT BYTES IN THE RECORD. 016E GOTO L F CALL GET_HEX_BYTE ; READ CHECKSUM C BTFSC BYTE_ERROR GOTO L2820 ; BYTE ERROR C GOTO L2790 ; READ ANOTHER RECORD L2810: CALL GET_HEX_BYTE ; READ ADDRESS HIGH C BTFSC BYTE_ERROR GOTO L2820 ; INPUT BYTE ERROR CALL GET_HEX_BYTE ; READ ADDRESS LOW C BTFSC BYTE_ERROR GOTO L2820 ; INPUT BYTE ERROR CALL GET_HEX_BYTE ; READ RECORD TYPE. 017A 193C BTFSC BYTE_ERROR 017B GOTO L2820 ; INPUT BYTE ERROR. 017C CALL GET_HEX_BYTE ; READ CHECKSUM. 017D 193C BTFSC BYTE_ERROR 017E GOTO L2820 ; INPUT BYTE ERROR. 017F CALL POWER_DOWN CLRF T2CON CALL VERIFY_SUCCESSFUL GOTO MENU_LOOP_ L2820: CALL POWER_DOWN CLRF T2CON CALL EMPTY_BUFFER CALL INPUT_BYTE_ERROR GOTO MENU_LOOP_ L2830: CALL POWER_DOWN CLRF T2CON ; STOP TIMER A CALL EMPTY_BUFFER 018B CALL VERIFY_ERROR 018C GOTO MENU_LOOP_10 018D L2835: 018D 15BC BSF ADDRESS_DIFFERENCE 018E GOTO L ; F READ_DEVICE_BINARY: F CALL CODE_DATA CB CALL BLUE_ON MOVLW READ_MODE CALL SET_MODE F CALL START_TIMER_ MOVLW A MOVWF BYTE_COUNT_HI L2500: A CLRF BYTE_COUNT_LO L2510: MOVF PORTB,W A MOVWF SERIAL_BYTE A CALL SERIAL_OUT A 232A CALL INCREMENT_ADDRESS_COUNTER B CALL TOGGLE_BLUE C 0BA DECFSZ BYTE_COUNT_LO,F 019D GOTO L2510

11 MPASM 5.46 AT89C2051_PROGRAMMER.ASM :21:50 PAGE E 0BA DECFSZ BYTE_COUNT_HI,F 019F GOTO L A CALL LF 01A CALL POWER_DOWN 01A CLRF T2CON ; STOP TIMER 2. 01A GOTO MENU_LOOP_ ; A READ_DEVICE_HEX: A CALL CODE_DATA A5 22CB CALL BLUE_ON A MOVLW READ_MODE 01A CALL SET_MODE A8 235F CALL START_TIMER_ A9 01C CLRF MASTER_ADDR_HI 01AA 01C CLRF MASTER_ADDR_LO 01AB MOVLW 16 01AC 00C MOVWF COLUMN_COUNTER 01AD MOVLW 8 01AE 00A MOVWF BYTE_COUNT_HI 01AF L2770: 01AF 01A CLRF BYTE_COUNT_LO 01B L2780: 01B0 1E BTFSS COLUMN_COUNTER,4 01B1 29B GOTO $ B MOVF MASTER_ADDR_HI,W 01B3 234C CALL SEND_HEX_BYTES B MOVF MASTER_ADDR_LO,W 01B5 234C CALL SEND_HEX_BYTES B6 22C CALL BLANK_SPACE B MOVF PORTB,W 01B8 234C CALL SEND_HEX_BYTES B9 22C CALL BLANK_SPACE BA 0BC DECFSZ COLUMN_COUNTER,F 01BB 29BF GOTO $+4 01BC CALL LF 01BD MOVLW 16 01BE 00C MOVWF COLUMN_COUNTER BF 232A CALL INCREMENT_ADDRESS_COUNTER C CALL TOGGLE_BLUE C MOVLW 1 ; INCREMENT MASTER ADDRESS. 01C2 07C ADDWF MASTER_ADDR_LO,F 01C BTFSC _C 01C4 07C ADDWF MASTER_ADDR_HI,F C5 0BA DECFSZ BYTE_COUNT_LO,F 01C6 29B GOTO L C7 0BA DECFSZ BYTE_COUNT_HI,F 01C8 29AF GOTO L C CALL POWER_DOWN 01CA CLRF T2CON ; STOP TIMER 2. 01CB GOTO MENU_LOOP_ ; CC READ_SIGNATURE_BYTES: CC 22CB CALL BLUE_ON CD MOVLW SIGNATURE_MODE 01CE CALL SET_MODE CF MOVLW SIGNATURE_BYTE_0 01D MOVWF FSR 01D MOVLW 3 01D2 00BF MOVWF SIGNATURE_BYTE_COUNTER D MOVF PORTB,W 01D MOVWF INDF D5 232A CALL INCREMENT_ADDRESS_COUNTER D6 0A INCF FSR,F 01D7 0BBF DECFSZ SIGNATURE_BYTE_COUNTER,F 01D8 29D GOTO $ D CALL SIGNATURE_BYTES DA MOVLW SIGNATURE_BYTE_0 01DB MOVWF FSR 01DC MOVLW 3

12 MPASM 5.46 AT89C2051_PROGRAMMER.ASM :21:50 PAGE 12 01DD MOVF INDF,W 01DE 234C CALL SEND_HEX_BYTES DF 22C CALL BLANK_SPACE 01E0 22D CALL DASH 01E1 22C CALL BLANK_SPACE 01E2 301E MOVLW 1EH ; TEST FOR ATMEL DEVICE. 01E XORWF INDF,W 01E4 1D BTFSS _Z 01E5 29E GOTO $+3 01E CALL ATMEL_DEVICE 01E7 29E GOTO $+2 01E8 239D CALL UNKNOWN_DEVICE 01E9 0A INCF FSR,F 01EA MOVF INDF,W 01EB 234C CALL SEND_HEX_BYTES EC 22C CALL BLANK_SPACE 01ED 22D CALL DASH 01EE 22C CALL BLANK_SPACE 01EF MOVLW 21H ; TEST FOR 89C F XORWF INDF,W 01F1 1D BTFSS _Z 01F2 29F GOTO $+3 01F3 239B CALL AT89C F4 29F GOTO $+2 01F5 239F CALL UNKNOWN_TYPE 01F6 0A INCF FSR,F 01F MOVF INDF,W 01F8 234C CALL SEND_HEX_BYTES F CALL LF 01FA CALL POWER_DOWN 01FB GOTO MENU_LOOP_ ; FC LOCK_BITS: 01FC CALL RED_ON FD CALL PRESS_1OR FE BCF CTS ; ALLOW BYTES TO BE SENT FROM CONSOLE. 01FF CALL SERIAL_IN MOVLW "1" XORWF SERIAL_BYTE,W BTFSC _Z A GOTO LOCK MOVLW "2" XORWF SERIAL_BYTE,W D BTFSS _Z FF GOTO $-8 ; LOOP UNTIL A '1' OR A '2' IS RECEIVED LOCK: BSF CTS ; CONSOLE BYTES NOT NEEDED NOW C MOVLW LOCK_MODE_1 020A CALL SET_MODE B BCF _12V_5V 020C BCF VPP_OFF 020D 22E CALL DELAY_1MS E BCF PROG 020F 2A GOTO $ A GOTO $ BSF PROG CALL WAIT_PROG MOVLW "2" ; LOCK MODE XORWF SERIAL_BYTE,W D BTFSS _Z A GOTO LOCK_END C MOVLW LOCK_MODE_ CALL SET_MODE BCF _12V_5V ; SET VPP TO 12V. 021A BCF VPP_OFF ; VPP-HIGH. 021B 22E CALL DELAY_1MS C BCF PROG 021D 2A1E GOTO $+1 021E 2A1F GOTO $+1 021F BSF PROG CALL WAIT_PROG ; WAIT PROG IS 2x 1ms DELAYS LOCK_END: MOVLW "1" XORWF SERIAL_BYTE,W BTFSC _Z A GOTO $ F CALL LOCK_BIT_ CALL POWER_DOWN GOTO MENU_LOOP_ D CALL LOCK_BIT_ CALL POWER_DOWN

13 MPASM 5.46 AT89C2051_PROGRAMMER.ASM :21:50 PAGE A GOTO MENU_LOOP_10

14 MPASM 5.46 AT89C2051_PROGRAMMER.ASM :21:50 PAGE PAGE ; ; ; / ) _ \ / _ \ \ / ; \ \ _ \ _) \ _ \ \ ; ) _ _) _ < _ _ \ ) ; / \ / / _ \_\\ / \ / _ _ \_ / ; ; B CHIP_ERASE: 022B CALL RED_ON C MOVLW ERASE_MODE 022D CALL SET_MODE E BCF _12V_5V ; SET VPP TO 12V. 022F BCF VPP_OFF ; VPP-HIGH E CALL DELAY_1MS BCF PROG ; ERASE TAKES PLACE HERE DA CALL DELAY_10MS BSF PROG BSF _12V_5V ; BRING VPP DOWN TO 5V DA CALL DELAY_10MS CALL POWER_DOWN CALL DEVICE_ERASED RETURN ; ; FETCH BYTE ; ~~~~~~~~~~ ; FETCH BYTE CHECKS SERIAL_BUFFER_COUNTER TO SEE IF THERE ARE ANY BYTES AVAILABLE. IF SO, THE OLDEST ; BYTE IS READ AND PLACED IN BUFFER_BYTE. BUFFER_FLAG IS SET WHEN A BYTE IS READ AND CLEARED IF NO BYTE ; IS FOUND FETCH_BYTE: A MOVF SERIAL_BUFFER_COUNTER,F ; SEE IF BYTES ARE AVAILABLE IN BUFFER. 023A 1D BTFSS _Z 023B 2A GOTO $+7 ; BUFFER HAS BYTES. 023C CALL FILL_BUFFER 023D 08A MOVF SERIAL_BUFFER_COUNTER,F 023E 1D BTFSS _Z ; BUFFER IS EMPTY. 023F 2A GOTO $+3 ; BUFFER HAS BYTES C BCF BUFFER_FLAG RETURN MOVF INDF,W ; READ OLDEST BYTE BD MOVWF BUFFER_BYTE C BSF BUFFER_FLAG ; INDICATE BYTE FOUND A INCF FSR,F ; POINT TO NEXT BUFFER LOCATION A DECF SERIAL_BUFFER_COUNTER,F RETURN ; ; FILE INPUT DELAY ; ~~~~~~~~~~~~~~~~ ; FILE INPUT DELAY STARTS A 31 SECOND DELAY TO ALLOW THE USER TO START SENDING AN INPUT FILE. AFTER ; SECONDS OR A KEY PRESS A RETURN IS EXECUTED FILE_INPUT_DELAY: E MOVLW 30 ; WAIT FOR 30 SECONDS BB MOVWF THIRTY_SEC_DELAY 024A 22EE CALL DELAY_1S 024B MOVLW 1 024C XORWF PORTC,F 024D 1C BTFSS PRESS_SWITCH ; CHECK PRESS SWITCH. 024E 2A GOTO $+3 ; PRESS SWITCH DOWN, SHORTEN DELAY TIME. 024F 0BBB DECFSZ THIRTY_SEC_DELAY,F ; PRESS SWITCH UP, CONTINUE COUNTDOWN A4A GOTO $ EE CALL DELAY_1S BD CALL ALL_OFF RETURN ; ; FILL BUFFER ; ~~~~~~~~~~~ ; FILL BUFFER RETURNS WITH AS MANY BYTES AS ARE AVAILABLE FROM THE SERIAL PORT. THE BUFFER HAS A ; CAPACITY OF 16 BYTES TO CORRESPOND WITH THE HOST PC SERIAL BUFFER. BUFFER BYTES ARE COUNTED BY ; SERIAL_BUFFER_COUNTER. A ZERO INDICATES THAT THE BUFFER IS EMPTY FILL_BUFFER: B MOVLW SERIAL_BUFFER ; POINT TO START OF BUFFER MOVWF FSR A CLRF SERIAL_BUFFER_COUNTER ; INITIAL NUMBER OF BYTES A BTFSC RTS ; MAKE SURE HOST IS READY A GOTO $ BCF CTS ; TRIGGER 16 BYTE TRANSMISSION. 025A 22AE CALL TIMED_SERIAL_IN ; FETCH BYTES IF THEY ARE AVAILABLE.

15 MPASM 5.46 AT89C2051_PROGRAMMER.ASM :21:50 PAGE B BSF CTS 025C 1CBC BTFSS BYTE_FLAG 025D 2A GOTO L E MOVF SERIAL_BYTE,W ; STORE NEW BYTE IN BUFFER. 025F MOVWF INDF A INCF FSR,F ; POINT TO NEXT BUFFER LOCATION AA INCF SERIAL_BUFFER_COUNTER,F ; COUNT BUFFER LOCATIONS MOVLW 16 ; FEST TO SEE IF BUFFER IS FULL XORWF SERIAL_BUFFER_COUNTER,W D BTFSS _Z A5A GOTO $ L2680: B MOVLW SERIAL_BUFFER ; POINT TO TOP OF BUFFER MOVWF FSR RETURN ; ; GET HEX BYTE ; ~~~~~~~~~~~~ ; GET HEX BYTE READS TWO BYTES FROM THE SERIAL BUFFER. IT CALLS FETCH BYTE AND, BEFORE CONVERTING THE ; ASCII CHARACTER TO HEX,IT CHECKS THAT A VALID BYTE WAS RECEIVED. IF THE BYTE WAS NOT VALID, A RETURN ; IS EXECUTED WITH THE BYTE ERROR BIT SET. IF THE BYTE WAS VALID, FETCH BYTE IS CALLED AGAIN. A VALID ; HEX BYTE IS RETURNED IN HEX_ WITH BYTE ERROR CLEAR. AS BEFORE, IF THE BYTE WAS INVALID, BYTE ; ERROR IS SET GET_HEX_BYTE: C BSF BYTE_ERROR ; BIT IS SET IN ANTICIPATION OF AN ERROR. 026A CALL FETCH_BYTE ; READ FIRST FROM SERIAL BUFFER. 026B 1C3C BTFSS BUFFER_FLAG 026C RETURN ; ERROR FOUND, INVALID BYTE. 026D 22C CALL ASCII_BINARY ; BYTE VALID, CONVERT IT TO BINARY. 026E 00A MOVWF HEX_ 026F 0EA SWAPF HEX_,F CALL FETCH_BYTE C3C BTFSS BUFFER_FLAG RETURN ; INVALID BYTE C CALL ASCII_BINARY A IORWF HEX_,F C BCF BYTE_ERROR ; INDICATE VALID BYTE RETURN ; ; SET MODE ; ~~~~~~~~ SET_MODE: CA MOVWF MODE ; SAVE MODE C MOVLW STEP_1 ; VCC ON, RST AND XTAL1= MOVWF PORTD 027A 22DA CALL DELAY_10MS B MOVLW STEP_2 ; RST/VPP AND P3.2/PROG="H". 027C MOVWF PORTD 027D 22DA CALL DELAY_10MS E MOVLW SIGNATURE_MODE 027F 064A XORWF MODE,W D BTFSS _Z A GOTO $ CALL PORTB_INPUT MOVLW SIGNATURE_MODE IORWF PORTD,F RETURN MOVLW READ_MODE A XORWF MODE,W D BTFSS _Z A8E GOTO $+5 028A CALL PORTB_INPUT 028B MOVLW READ_MODE 028C IORWF PORTD,F 028D RETURN E MOVLW WRITE_MODE 028F 064A XORWF MODE,W D BTFSS _Z A9A GOTO $ D CALL PORTB_OUTPUT MOVLW WRITE_MODE IORWF PORTD,F DA CALL DELAY_10MS F MOVLW 3FH ; RST TO +12V ANDWF PORTD,F DA CALL DELAY_10MS RETURN A MOVLW ERASE_MODE 029B 064A XORWF MODE,W 029C 1D BTFSS _Z 029D 2AA GOTO $+5 029E 233D CALL PORTB_OUTPUT 029F MOVLW ERASE_MODE 02A IORWF PORTD,F

16 MPASM 5.46 AT89C2051_PROGRAMMER.ASM :21:50 PAGE 16 02A RETURN A2 300C MOVLW LOCK_MODE_2 02A3 064A XORWF MODE,W 02A4 1D BTFSS _Z 02A5 2AAA GOTO $+5 02A6 233D CALL PORTB_OUTPUT 02A7 300C MOVLW LOCK_MODE_2 02A IORWF PORTD,F 02A RETURN AA 233D CALL PORTB_OUTPUT 02AB 301C MOVLW LOCK_MODE_1 02AC IORWF PORTD,F 02AD RETURN ; ; TIMED SERIAL IN ; ~~~~~~~~~~~~~~~ ; TIMER 1 IS CONFIGURED TO PROVIDE A 142 MILLISECOND DELAY. TIMED SERIAL IN RESTARTS TIMER 1, WAITS FOR ; TIMEOUT OR FOR A SERIAL INPUT. BYTE FLAG IS SET ACCORDING TO THE RESULTS AE TIMED_SERIAL_IN: AE BCF T1CON,TMR1ON ; STOP TIMER 1. 02AF 100C BCF PIR1,TMR1IF ; RESET TIMER 1. 02B0 018F CLRF TMR1H 02B1 018E CLRF TMR1L 02B BSF T1CON,TMR1ON ; START TIMER 1. 02B3 180C BTFSC PIR1,TMR1IF ; CHECK FOR TIMEOUT. 02B4 2ABB GOTO $+7 ; TIMER 1 TIMEOUT. 02B5 1E8C BTFSS PIR1,RCIF ; CHECK FOR SERIAL INPUT. 02B6 2AB GOTO $-3 ; KEEP TESTING FOR TIMEOUT AND SERIAL INPUT. 02B7 081A MOVF RCREG,W ; SERIAL INPUT FOUND. 02B8 00A MOVWF SERIAL_BYTE 02B9 14BC BSF BYTE_FLAG 02BA RETURN 02BB 10BC BCF BYTE_FLAG ; TIMER ONE TIMED OUT BEFORE SERIAL BYTE ARRIVED. 02BC RETURN ; ; MINOR SUBROUTINES ; BD ALL_OFF: 02BD 30F MOVLW 0F8H ; MASK ALL LED OUTPUTS. 02BE ANDWF PORTC,F ; SWITCH OFF RED, GREEN AND BLUE LEDS. 02BF RETURN ; C ASCII_BINARY: 02C0 083D MOVF BUFFER_BYTE,W 02C1 3EBF ADDLW -41H 02C2 1C BTFSS _C 02C3 3E ADDLW 7 02C4 3E0A ADDLW 10 02C RETURN ; C BLANK_SPACE: 02C6 1E0C BTFSS PIR1,TXIF 02C7 2AC GOTO $-1 02C MOVLW " " 02C MOVWF TXREG 02CA RETURN ; CB BLUE_ON: 02CB BCF RED 02CC BCF GREEN 02CD BSF BLUE 02CE RETURN ; ; CONVERT HEX2ASC ; ~~~~~~~~~~~~~~~ ; CONVERT HEX2ASC DOES THE ACTUAL CONVERSION FOR HEX_TO_ASCII, RETURNING WITH THE RESULT IN W CF CONVERT_HEX2ASC: CF 390F ANDLW 0FH ; MASK UPPER NYBBLE. 02D0 3E ADDLW 6 02D BTFSC _DC 02D2 3E ADDLW 'A'-('9'+1) 02D3 3E2A ADDLW '0'-6 ; RESULT IS IN W. 02D RETURN ;

17 MPASM 5.46 AT89C2051_PROGRAMMER.ASM :21:50 PAGE 17 02D DASH: 02D5 1E0C BTFSS PIR1,TXIF 02D6 2AD GOTO $-1 02D7 302D MOVLW "-" 02D MOVWF TXREG 02D RETURN ; DA DELAY_10MS: 02DA MOVLW 32H 02DB 00A MOVWF D1 02DC MOVLW 8 02DD 00A MOVWF D2 02DE DELAY_10MS_0: 02DE 0BA DECFSZ D1,F 02DF 2AE GOTO $+2 02E0 0BA DECFSZ D2,F 02E1 2ADE GOTO DELAY_10MS_0 02E2 2AE GOTO $+1 02E RETURN ; E DELAY_1MS: 02E4 30B MOVLW 0B7H 02E5 00A MOVWF D1 02E MOVLW 1 02E7 00A MOVWF D2 02E DELAY_1MS_0: 02E8 0BA DECFSZ D1,F 02E9 2AEB GOTO $+2 02EA 0BA DECFSZ D2,F 02EB 2AE GOTO DELAY_1MS_0 02EC 2AED GOTO $+1 02ED RETURN ; EE DELAY_1S: 02EE MOVLW 47H ; ONE SECOND DELAY. 02EF 00A MOVWF D1 02F MOVLW 3 02F1 00A MOVWF D2 02F MOVLW 3 02F3 00A MOVWF D3 02F DELAY_1SEC: 02F4 0BA DECFSZ D1,F 02F5 2AF GOTO $+2 02F6 0BA DECFSZ D2,F 02F7 2AF GOTO $+2 02F8 0BA DECFSZ D3,F 02F9 2AF GOTO DELAY_1SEC 02FA 2AFB GOTO $+1 02FB 2AFC GOTO $+1 02FC 2AFD GOTO $+1 02FD RETURN ; FE DELAY_30S: 02FE 301E MOVLW 30 ; WAIT FOR 30 SECONDS. 02FF 00BB MOVWF THIRTY_SEC_DELAY EE CALL DELAY_1S MOVLW XORWF PORTC,F BBB DECFSZ THIRTY_SEC_DELAY,F B GOTO $ RETURN ; DELAY_500US: MOVLW 98H A MOVWF D DELAY_500: BA DECFSZ D1,F B GOTO DELAY_ A RETURN ; B DRAW_LINE: 030B MOVLW C 00A MOVWF BYTE_COUNT 030D 22D CALL DASH 030E 0BA DECFSZ BYTE_COUNT,F 030F 2B0D GOTO $ RETURN ; ; EMPTY BUFFER ; ~~~~~~~~~~~~ ; EMPTY BUFFER IS USED TO CLEAR THE BUFFER AFTER AN ERROR.

18 MPASM 5.46 AT89C2051_PROGRAMMER.ASM :21:50 PAGE EMPTY_BUFFER: BCF CTS ; READ BYTES FROM BUFFER UNTIL IT IS EMPTY AE CALL TIMED_SERIAL_IN BC BTFSC BYTE_FLAG B GOTO $ BSF CTS B MOVLW SERIAL_BUFFER ; RE-INITIALISE BUFFER MOVWF FSR A CLRF SERIAL_BUFFER_COUNTER RETURN ; A GREEN_ON: 031A BCF RED 031B BSF GREEN 031C BCF BLUE 031D RETURN ; ; HEX TO ASCII ; ~~~~~~~~~~~~ ; HEX TO ASCII CONVERTS THE HEXADECIMAL BYTE IN ASCII_CHAR_HI TO TWO ASCII CHARACTERS, RETURNING THEM IN ; ASCII_CHAR_HI AND ASCII_CHAR_LO E HEX_TO_ASCII: E 0E SWAPF ASCII_CHAR_HI,W 031F 22CF CALL CONVERT_HEX2ASC XORWF ASCII_CHAR_HI,W C XORWF ASCII_CHAR_HI,F XORWF ASCII_CHAR_HI,W CF CALL CONVERT_HEX2ASC C MOVWF ASCII_CHAR_LO RETURN ; INCREMENT_ADDRESS: AAA INCF ADDRESS_LO,F ;INCREMENT RECORD ADDRESS BTFSC _Z AA INCF ADDRESS_HI,F RETURN ; A INCREMENT_ADDRESS_COUNTER: 032A BSF XTAL1 032B 2B2C GOTO $+1 032C 2B2D GOTO $+1 032D BCF XTAL1 032E RETURN ; F INCREMENT_MASTER_ADDRESS: 032F 0AC INCF MASTER_ADDR_LO,F BTFSC _Z AC INCF MASTER_ADDR_HI,F RETURN ; LF: E0C BTFSS PIR1,TXIF B GOTO $ A MOVLW 0AH MOVWF TXREG RETURN ; PORTB_INPUT: BSF _RP0 ; BANK FF MOVLW 0FFH ; PORTB - INPUTS - WEAK PULL-UPS. 033A MOVWF TRISB 033B BCF _RP0 ; BANK C RETURN ; D PORTB_OUTPUT: 033D CLRF PORTB ; ALL PINS LOW. 033E BSF _RP0 ; BANK F CLRF TRISB ; ALL PINS OUTPUT BCF _RP0 ; BANK RETURN ; ; POWER DOWN ; ~~~~~~~~~~

19 MPASM 5.46 AT89C2051_PROGRAMMER.ASM :21:50 PAGE ; POWER DOWN REMOVES POWER FROM THE PROGRAMMING SOCKET IN ACCORDANCE WITH INSTRUCTION 10 OF THE ; PROGRAMMING ALGORITHM FOR THE AT89C POWER_DOWN: BCF XTAL BSF VPP_OFF E MOVLW 0E0H MOVWF PORTD D CALL PORTB_OUTPUT RETURN ; RED_ON: BSF RED BCF GREEN 034A BCF BLUE 034B RETURN ; ; SEND HEX BYTES ; ~~~~~~~~~~~~~~ C SEND_HEX_BYTES: 034C 00C MOVWF ASCII_CHAR_HI 034D 231E CALL HEX_TO_ASCII 034E MOVF ASCII_CHAR_HI,W 034F 00A MOVWF SERIAL_BYTE A CALL SERIAL_OUT MOVF ASCII_CHAR_LO,W A MOVWF SERIAL_BYTE A CALL SERIAL_OUT RETURN ; SERIAL_IN: E8C BTFSS PIR1,RCIF ; WAIT FOR SERIAL INPUT B GOTO $ A MOVF RCREG,W ; FETCH AND STORE SERIAL BYTE A MOVWF SERIAL_BYTE RETURN ; A SERIAL_OUT: 035A 1E0C BTFSS PIR1,TXIF ; WAIT FOR TX BUFFER TO EMPTY. 035B 2B5A GOTO $-1 035C MOVF SERIAL_BYTE,W 035D MOVWF TXREG 035E RETURN ; F START_TIMER_2: 035F 108C BCF PIR1,TMR2IF ; CLEAR INTERRUPT FLAG CLRF TMR F MOVLW 7FH ; TIMER 2, POSTSCALER 1:16, PRESCALER 1: MOVWF T2CON RETURN ; TOGGLE_BLUE: C8C BTFSS PIR1,TMR2IF ; TIMEOUT? B GOTO $+4 ; NOT YET C BCF PIR1,TMR2IF ; CLEAR INTERRUPT FLAG MOVLW 4 ; TOGGLE BLUE LED XORWF PORTC,F RETURN ; A TOGGLE_RED: 036A 1C8C BTFSS PIR1,TMR2IF ; TIMEOUT? 036B 2B6F GOTO $+4 ; NOT YET. 036C 108C BCF PIR1,TMR2IF ; CLEAR INTERRUPT FLAG. 036D MOVLW 1 ; TOGGLE RED LED. 036E XORWF PORTC,F 036F RETURN ; WAIT_PROG: E CALL DELAY_1MS E CALL DELAY_1MS RETURN ; ; ; \/ / / / \ / / ; \/ _ \ \ \ / _ \ _ _ \ \ ; ) ) / \ _ ) ; _ _ / /_/ \_\ /

Outlines. PIC Programming in C and Assembly. Krerk Piromsopa, Ph.D. Department of Computer Engineering Chulalongkorn University

Outlines. PIC Programming in C and Assembly. Krerk Piromsopa, Ph.D. Department of Computer Engineering Chulalongkorn University PIC ming in C and Assembly Outlines Microprocessor vs. MicroController PIC in depth PIC ming Assembly ming Krerk Piromsopa, Ph.D. Department of Computer Engineering Chulalongkorn University Embedded C

More information

Lecture (04) PIC16F84A (3)

Lecture (04) PIC16F84A (3) Lecture (04) PIC16F84A (3) By: Dr. Ahmed ElShafee ١ Central Processing Unit Central processing unit (CPU) is the brain of a microcontroller responsible for finding and fetching the right instruction which

More information

PIC 16F84A programming (II)

PIC 16F84A programming (II) Lecture (05) PIC 16F84A programming (II) Dr. Ahmed M. ElShafee ١ Introduction to 16F84 ٣ PIC16F84 belongs to a class of 8-bit microcontrollers of RISC architecture. Program memory (FLASH) EEPROM RAM PORTA

More information

Hardware Interfacing. EE25M Introduction to microprocessors. Part V. 15 Interfacing methods. original author: Feisal Mohammed

Hardware Interfacing. EE25M Introduction to microprocessors. Part V. 15 Interfacing methods. original author: Feisal Mohammed EE25M Introduction to microprocessors original author: Feisal Mohammed updated: 18th February 2002 CLR Part V Hardware Interfacing There are several features of computers/microcontrollers which have not

More information

Lesson 14. Title of the Experiment: Introduction to Microcontroller (Activity number of the GCE Advanced Level practical Guide 27)

Lesson 14. Title of the Experiment: Introduction to Microcontroller (Activity number of the GCE Advanced Level practical Guide 27) Lesson 14 Title of the Experiment: Introduction to Microcontroller (Activity number of the GCE Advanced Level practical Guide 27) Name and affiliation of the author: N W K Jayatissa Department of Physics,

More information

Embedded System Design

Embedded System Design ĐẠI HỌC QUỐC GIA TP.HỒ CHÍ MINH TRƯỜNG ĐẠI HỌC BÁCH KHOA KHOA ĐIỆN-ĐIỆN TỬ BỘ MÔN KỸ THUẬT ĐIỆN TỬ Embedded System Design : Microcontroller 1. Introduction to PIC microcontroller 2. PIC16F84 3. PIC16F877

More information

Assembly Language Instructions

Assembly Language Instructions Assembly Language Instructions Content: Assembly language instructions of PIC16F887. Programming by assembly language. Prepared By- Mohammed Abdul kader Assistant Professor, EEE, IIUC Assembly Language

More information

EEE111A/B Microprocessors

EEE111A/B Microprocessors EEE111A/B Microprocessors Revision Notes Lecture 1: What s it all About? Covers the basic principles of digital signals. The intelligence of virtually all communications, control and electronic devices

More information

Chapter 4 Sections 1 4, 10 Dr. Iyad Jafar

Chapter 4 Sections 1 4, 10 Dr. Iyad Jafar Starting to Program Chapter 4 Sections 1 4, 10 Dr. Iyad Jafar Outline Introduction Program Development Process The PIC 16F84A Instruction Set Examples The PIC 16F84A Instruction Encoding Assembler Details

More information

CIS-331 Exam 2 Fall 2015 Total of 105 Points Version 1

CIS-331 Exam 2 Fall 2015 Total of 105 Points Version 1 Version 1 1. (20 Points) Given the class A network address 117.0.0.0 will be divided into multiple subnets. a. (5 Points) How many bits will be necessary to address 4,000 subnets? b. (5 Points) What is

More information

UNIVERSITY OF ULSTER UNIVERSITY EXAMINATIONS : 2001/2002 RESIT. Year 2 MICROCONTROLLER SYSTEMS. Module Code: EEE305J1. Time allowed: 3 Hours

UNIVERSITY OF ULSTER UNIVERSITY EXAMINATIONS : 2001/2002 RESIT. Year 2 MICROCONTROLLER SYSTEMS. Module Code: EEE305J1. Time allowed: 3 Hours UNIVERSITY OF ULSTER UNIVERSITY EXAMINATIONS : 2001/2002 RESIT Year 2 MICROCONTROLLER SYSTEMS Module Code: EEE305J1 Time allowed: 3 Hours Answer as many questions as you can. Not more than TWO questions

More information

UNIVERSITY OF ULSTER UNIVERSITY EXAMINATIONS : 2001/2002. Semester 2. Year 2 MICROCONTROLLER SYSTEMS. Module Code: EEE305J2. Time allowed: 3 Hours

UNIVERSITY OF ULSTER UNIVERSITY EXAMINATIONS : 2001/2002. Semester 2. Year 2 MICROCONTROLLER SYSTEMS. Module Code: EEE305J2. Time allowed: 3 Hours UNIVERSITY OF ULSTER UNIVERSITY EXAMINATIONS : 2001/2002 Semester 2 Year 2 MICROCONTROLLER SYSTEMS Module Code: EEE305J2 Time allowed: 3 Hours Answer as many questions as you can. Not more than TWO questions

More information

Embedded Systems. PIC16F84A Sample Programs. Eng. Anis Nazer First Semester

Embedded Systems. PIC16F84A Sample Programs. Eng. Anis Nazer First Semester Embedded Systems PIC16F84A Sample Programs Eng. Anis Nazer First Semester 2017-2018 Development cycle (1) Write code (2) Assemble / compile (3) Simulate (4) Download to MCU (5) Test Inputs / Outputs PIC16F84A

More information

PIC Discussion. By Eng. Tamar Jomaa

PIC Discussion. By Eng. Tamar Jomaa PIC Discussion By Eng. Tamar Jomaa Chapter#2 Programming Microcontroller Using Assembly Language Quiz#1 : Time: 10 minutes Marks: 10 Fill in spaces: 1) PIC is abbreviation for 2) Microcontroller with..architecture

More information

AN587. Interfacing to an LCD Module. Interfacing to an LCD Module INTRODUCTION OPERATION CONTROL SIGNAL FUNCTIONS TABLE 2: CONDITIONAL ASSEMBLY FLAGS

AN587. Interfacing to an LCD Module. Interfacing to an LCD Module INTRODUCTION OPERATION CONTROL SIGNAL FUNCTIONS TABLE 2: CONDITIONAL ASSEMBLY FLAGS Interfacing to an LCD Module AN587 INTRODUCTION TABLE 1: CONTROL SIGNAL FUNCTIONS This application note interfaces a PIC16CXX device to the Hitachi LM02L LCD character display module. This module is a

More information

PIC16F87X 13.0 INSTRUCTION SET SUMMARY INSTRUCTIONS DESCRIPTIONS

PIC16F87X 13.0 INSTRUCTION SET SUMMARY INSTRUCTIONS DESCRIPTIONS PIC6F87X 3.0 INSTRUCTION SET SUMMARY Each PIC6F87X instruction is a 4bit word, divided into an OPCODE which specifies the instruction type and one or more operands which further specify the operation of

More information

CIS-331 Fall 2013 Exam 1 Name: Total of 120 Points Version 1

CIS-331 Fall 2013 Exam 1 Name: Total of 120 Points Version 1 Version 1 1. (24 Points) Show the routing tables for routers A, B, C, and D. Make sure you account for traffic to the Internet. NOTE: Router E should only be used for Internet traffic. Router A Router

More information

4. Specifications and Additional Information

4. Specifications and Additional Information 4. Specifications and Additional Information AGX52004-1.0 8B/10B Code This section provides information about the data and control codes for Arria GX devices. Code Notation The 8B/10B data and control

More information

University of Jordan Faculty of Engineering and Technology Department of Computer Engineering Embedded Systems Laboratory

University of Jordan Faculty of Engineering and Technology Department of Computer Engineering Embedded Systems Laboratory University of Jordan Faculty of Engineering and Technology Department of Computer Engineering Embedded Systems Laboratory 0907334 6 Experiment 6:Timers Objectives To become familiar with hardware timing

More information

Flow Charts and Assembler Programs

Flow Charts and Assembler Programs Flow Charts and Assembler Programs Flow Charts: A flow chart is a graphical way to display how a program works (i.e. the algorithm). The purpose of a flow chart is to make the program easier to understand.

More information

Computer Engineering Capstone Design Summer A : Handheld Video Games

Computer Engineering Capstone Design Summer A : Handheld Video Games Computer Engineering Capstone Design Summer A 99 0: Handheld Video Games J. S. McDonald Odd-Wednesday Talks May, 0 http://www.kettering.edu/~mcdonald/ece0/ PIC-Pong By Rickard Gunée; uses a -MHz PICF and

More information

Week1. EEE305 Microcontroller Key Points

Week1. EEE305 Microcontroller Key Points Week1 Harvard Architecture Fig. 3.2 Separate Program store and Data (File) stores with separate Data and Address buses. Program store Has a 14-bit Data bus and 13-bit Address bus. Thus up to 2 13 (8K)

More information

CIS-331 Exam 2 Fall 2014 Total of 105 Points. Version 1

CIS-331 Exam 2 Fall 2014 Total of 105 Points. Version 1 Version 1 1. (20 Points) Given the class A network address 119.0.0.0 will be divided into a maximum of 15,900 subnets. a. (5 Points) How many bits will be necessary to address the 15,900 subnets? b. (5

More information

CIS-331 Fall 2014 Exam 1 Name: Total of 109 Points Version 1

CIS-331 Fall 2014 Exam 1 Name: Total of 109 Points Version 1 Version 1 1. (24 Points) Show the routing tables for routers A, B, C, and D. Make sure you account for traffic to the Internet. Router A Router B Router C Router D Network Next Hop Next Hop Next Hop Next

More information

C1098 JPEG Module User Manual

C1098 JPEG Module User Manual C1098 JPEG Module User Manual General Description C1098 is VGA camera module performs as a JPEG compressed still camera that can be attached to a wireless or PDA host. Users can send out a snapshot command

More information

ECE Homework #3

ECE Homework #3 ECE 376 - Homework #3 Flow Charts, Binary Inputs, Binary Outputs (LEDs). Due Monday, January 29th The temperature sensor in your lab kits has the temperature-resistance relationship of R = 1000 exp 3965

More information

TOPIC 3 INTRODUCTION TO PIC ASSEMBLY LANGUAGE. E4160 Microprocessor & Microcontroller System. Prepared by : Puziah Yahaya JKE, POLISAS / DEC 2010

TOPIC 3 INTRODUCTION TO PIC ASSEMBLY LANGUAGE. E4160 Microprocessor & Microcontroller System. Prepared by : Puziah Yahaya JKE, POLISAS / DEC 2010 TOPIC 3 INTRODUCTION TO PIC ASSEMBLY LANGUAGE Prepared by : Puziah Yahaya JKE, POLISAS / DEC 2010 E4160 Microprocessor & Microcontroller System Learning Outcomes 2 At the end of this topic, students should

More information

16.317: Microprocessor Systems Design I Fall 2013 Exam 3 Solution

16.317: Microprocessor Systems Design I Fall 2013 Exam 3 Solution 16.317: Microprocessor Systems Design I Fall 2013 Exam 3 Solution 1. (20 points, 5 points per part) Multiple choice For each of the multiple choice questions below, clearly indicate your response by circling

More information

CIS-331 Exam 2 Spring 2016 Total of 110 Points Version 1

CIS-331 Exam 2 Spring 2016 Total of 110 Points Version 1 Version 1 1. (20 Points) Given the class A network address 121.0.0.0 will be divided into multiple subnets. a. (5 Points) How many bits will be necessary to address 8,100 subnets? b. (5 Points) What is

More information

Binary Outputs and Timing

Binary Outputs and Timing Binary Outputs and Timing Each of the I/O pins on a PIC can be inputs or ourputs As an input, the pin is high impedance (meaning it is passive and draws very little current). If you apply 0V to that pin,

More information

PIC16C63A/65B/73B/74B

PIC16C63A/65B/73B/74B PI663A/65B/73B/74B 4.0 MEMORY ORGANIATION 4. Program Memory Organization The PI663A/65B/73B/74B has a 3bit program counter capable of addressing an 8K x 4 program memory space. All devices covered by this

More information

CIS-331 Spring 2016 Exam 1 Name: Total of 109 Points Version 1

CIS-331 Spring 2016 Exam 1 Name: Total of 109 Points Version 1 Version 1 Instructions Write your name on the exam paper. Write your name and version number on the top of the yellow paper. Answer Question 1 on the exam paper. Answer Questions 2-4 on the yellow paper.

More information

which means that writing to a port implies that the port pins are first read, then this value is modified and then written to the port data latch.

which means that writing to a port implies that the port pins are first read, then this value is modified and then written to the port data latch. Introduction to microprocessors Feisal Mohammed 3rd January 2001 Additional features 1 Input/Output Ports One of the features that differentiates a microcontroller from a microprocessor is the presence

More information

LAB WORK 2. 1) Debugger-Select Tool-MPLAB SIM View-Program Memory Trace the program by F7 button. Lab Work

LAB WORK 2. 1) Debugger-Select Tool-MPLAB SIM View-Program Memory Trace the program by F7 button. Lab Work LAB WORK 1 We are studying with PIC16F84A Microcontroller. We are responsible for writing assembly codes for the microcontroller. For the code, we are using MPLAB IDE software. After opening the software,

More information

CENG 336 INT. TO EMBEDDED SYSTEMS DEVELOPMENT. Spring 2006

CENG 336 INT. TO EMBEDDED SYSTEMS DEVELOPMENT. Spring 2006 CENG 336 INT. TO EMBEDDED SYSTEMS DEVELOPMENT Spring 2006 Recitation 01 21.02.2006 CEng336 1 OUTLINE LAB & Recitation Program PIC Architecture Overview PIC Instruction Set PIC Assembly Code Structure 21.02.2006

More information

PIC16F /40-Pin 8-Bit CMOS FLASH Microcontrollers. Devices Included in this Data Sheet: Pin Diagram PDIP. Microcontroller Core Features:

PIC16F /40-Pin 8-Bit CMOS FLASH Microcontrollers. Devices Included in this Data Sheet: Pin Diagram PDIP. Microcontroller Core Features: 28/40-Pin 8-Bit CMOS FLASH Microcontrollers Devices Included in this Data Sheet: PIC16F870 PIC16F871 Microcontroller Core Features: High-performance RISC CPU Only 35 single word instructions to learn All

More information

Target Board PIC877-TB - Reference Manual

Target Board PIC877-TB - Reference Manual Target Board PIC877-TB - Reference Manual 40-100-2 Target Board PIC877-TB Reference Manual 40-100-2 Feedback Feedback Instruments Ltd, Park Road, Crowborough, E. Sussex, TN6 2QR, UK. Telephone: +44 (0)

More information

EE6008-Microcontroller Based System Design Department Of EEE/ DCE

EE6008-Microcontroller Based System Design Department Of EEE/ DCE UNIT- II INTERRUPTS AND TIMERS PART A 1. What are the interrupts available in PIC? (Jan 14) Interrupt Source Enabled by Completion Status External interrupt from INT INTE = 1 INTF = 1 TMR0 interrupt T0IE

More information

SOLUTIONS!! DO NOT DISTRIBUTE!!

SOLUTIONS!! DO NOT DISTRIBUTE!! THE UNIVERSITY OF THE WEST INDIES EXAMINATIONS OF FEBRUARY MID-TERM 2005 Code and Name of Course: EE25M Introduction to Microprocessors Paper: Date and Time: Duration: One Hour INSTRUCTIONS TO CANDIDATES:

More information

When JP1 is cut, baud rate is Otherwise, baud rate is Factory default is that JP1 is shorted. (JP1 is jumper type in some model)

When JP1 is cut, baud rate is Otherwise, baud rate is Factory default is that JP1 is shorted. (JP1 is jumper type in some model) ELCD SERIES INTRODUCTION ALCD is Serial LCD module which is controlled through Serial communication. Most of existing LCD adopts Parallel communication which needs lots of control lines and complicated

More information

APPLICATION NOTE 2361 Interfacing an SPI-Interface RTC with a PIC Microcontroller

APPLICATION NOTE 2361 Interfacing an SPI-Interface RTC with a PIC Microcontroller Maxim/Dallas > App Notes > REAL-TIME CLOCKS Keywords: DS1305, SPI, PIC, real time clock, RTC, spi interface, pic microcontroller Aug 20, 2003 APPLICATION NOTE 2361 Interfacing an SPI-Interface RTC with

More information

PIC16F870/ /40-Pin, 8-Bit CMOS FLASH Microcontrollers. Devices Included in this Data Sheet: Pin Diagram. Microcontroller Core Features:

PIC16F870/ /40-Pin, 8-Bit CMOS FLASH Microcontrollers. Devices Included in this Data Sheet: Pin Diagram. Microcontroller Core Features: 28/40-Pin, 8-Bit CMOS FLASH Microcontrollers Devices Included in this Data Sheet: Pin Diagram PIC16F870 PIC16F871 PDIP Microcontroller Core Features: High performance RISC CPU Only 35 single word instructions

More information

PIC16F87X. 28/40-pin 8-Bit CMOS FLASH Microcontrollers. Devices Included in this Data Sheet: Pin Diagram PDIP. Microcontroller Core Features:

PIC16F87X. 28/40-pin 8-Bit CMOS FLASH Microcontrollers. Devices Included in this Data Sheet: Pin Diagram PDIP. Microcontroller Core Features: 28/40-pin 8-Bit CMOS FLASH Microcontrollers Devices Included in this Data Sheet: PIC16F873 PIC16F874 PIC16F876 PIC16F877 Microcontroller Core Features: High-performance RISC CPU Only 35 single word instructions

More information

APPLICATION NOTE Wire Communication with a Microchip PICmicro Microcontroller

APPLICATION NOTE Wire Communication with a Microchip PICmicro Microcontroller Maxim > App Notes > 1-Wire DEVICES BATTERY MANAGEMENT Keywords: 1-wire, PICmicro, Microchip PIC, 1-Wire communication, PIC microcontroller, PICmicro microcontroller, 1 wire communication, PICs, micros,

More information

Instuction set

Instuction set Instuction set http://www.piclist.com/images/www/hobby_elec/e_pic3_1.htm#1 In PIC16 series, RISC(Reduced Instruction Set Computer) is adopted and the number of the instructions to use is 35 kinds. When

More information

D:\PICstuff\PartCounter\PartCounter.asm

D:\PICstuff\PartCounter\PartCounter.asm 1 ;********************************************************************** 2 ; This file is a basic code template for assembly code generation * 3 ; on the PICmicro PIC16F84A. This file contains the basic

More information

/* PROGRAM FOR BLINKING LEDs CONEECTED TO PORT-D */

/* PROGRAM FOR BLINKING LEDs CONEECTED TO PORT-D */ /* PROGRAM FOR BLINKING LEDs CONEECTED TO PORT-D */ CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _HS_OSC & _WRT_OFF & _LVP_OFF & _CPD_OFF ;***** VARIABLE DEFINITIONS COUNT_L EQU 0x01 ;**********************************************************************

More information

Section 4. Architecture

Section 4. Architecture M Section 4. Architecture HIGHLIGHTS This section of the manual contains the following major topics: 4. Introduction...4-2 4.2 Clocking Scheme/Instruction Cycle...4-5 4.3 Instruction Flow/Pipelining...4-6

More information

CIS-331 Final Exam Spring 2015 Total of 115 Points. Version 1

CIS-331 Final Exam Spring 2015 Total of 115 Points. Version 1 Version 1 1. (25 Points) Given that a frame is formatted as follows: And given that a datagram is formatted as follows: And given that a TCP segment is formatted as follows: Assuming no options are present

More information

Section 11. Timer0. Timer0 HIGHLIGHTS. This section of the manual contains the following major topics:

Section 11. Timer0. Timer0 HIGHLIGHTS. This section of the manual contains the following major topics: M 11 Section 11. HIGHLIGHTS This section of the manual contains the following major topics: 11.1 Introduction...11-2 11.2 Control Register...11-3 11.3 Operation...11-4 11.4 TMR0 Interrupt...11-5 11.5 Using

More information

PIC16F7X Data Sheet. 28/40-pin, 8-bit CMOS FLASH Microcontrollers Microchip Technology Inc. DS30325B

PIC16F7X Data Sheet. 28/40-pin, 8-bit CMOS FLASH Microcontrollers Microchip Technology Inc. DS30325B M PIC16F7X Data Sheet 28/40-pin, 8-bit CMOS FLASH Microcontrollers 2002 Microchip Technology Inc. DS30325B Note the following details of the code protection feature on PICmicro MCUs. The PICmicro family

More information

Embedded Systems Programming and Architectures

Embedded Systems Programming and Architectures Embedded Systems Programming and Architectures Lecture No 10 : Data acquisition and data transfer Dr John Kalomiros Assis. Professor Department of Post Graduate studies in Communications and Informatics

More information

ECE Test #1: Name

ECE Test #1: Name ECE 376 - Test #1: Name Closed Book, Closed Notes. Calculators Permitted. September 23, 2016 20 15 10 5 0

More information

Dept. of Computer Engineering Final Exam, First Semester: 2016/2017

Dept. of Computer Engineering Final Exam, First Semester: 2016/2017 Philadelphia University Faculty of Engineering Course Title: Embedded Systems (630414) Instructor: Eng. Anis Nazer Dept. of Computer Engineering Final Exam, First Semester: 2016/2017 Student Name: Student

More information

CIS-331 Final Exam Spring 2018 Total of 120 Points. Version 1

CIS-331 Final Exam Spring 2018 Total of 120 Points. Version 1 Version 1 Instructions 1. Write your name and version number on the top of the yellow paper and the routing tables sheet. 2. Answer Question 2 on the routing tables sheet. 3. Answer Questions 1, 3, 4,

More information

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING. EE Microcontroller Based System Design

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING. EE Microcontroller Based System Design DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING EE6008 - Microcontroller Based System Design UNIT III PERIPHERALS AND INTERFACING PART A 1. What is an

More information

PIC16C84. 8-bit CMOS EEPROM Microcontroller PIC16C84. Pin Diagram. High Performance RISC CPU Features: CMOS Technology: Peripheral Features:

PIC16C84. 8-bit CMOS EEPROM Microcontroller PIC16C84. Pin Diagram. High Performance RISC CPU Features: CMOS Technology: Peripheral Features: 8-bit CMOS EEPROM Microcontroller High Performance RISC CPU Features: Only 35 single word instructions to learn All instructions single cycle (400 ns @ 10 MHz) except for program branches which are two-cycle

More information

SOLAR TRACKING SYSTEM USING PIC16F84A STEPPER MOTOR AND 555TIMER

SOLAR TRACKING SYSTEM USING PIC16F84A STEPPER MOTOR AND 555TIMER SOLAR TRACKING SYSTEM USING PIC16F84A STEPPER MOTOR AND 555TIMER Amey Arvind Madgaonkar 1, Sumit Dhere 2 & Rupesh Ratnakar Kadam 3 1. Block diagram International Journal of Latest Trends in Engineering

More information

CONNECT TO THE PIC. A Simple Development Board

CONNECT TO THE PIC. A Simple Development Board CONNECT TO THE PIC A Simple Development Board Ok, so you have now got your programmer, and you have a PIC or two. It is all very well knowing how to program the PIC in theory, but the real learning comes

More information

Interfacing PIC Microcontrollers. ADC8BIT2 Schematic. This application demonstrates analogue input sampling

Interfacing PIC Microcontrollers. ADC8BIT2 Schematic. This application demonstrates analogue input sampling Interfacing PIC Microcontrollers ADC8BIT2 Schematic This application demonstrates analogue input sampling A manually adjusted test voltage 0-5V is provided at AN0 input A reference voltage of 2.56V is

More information

Chapter 10 Sections 1,2,9,10 Dr. Iyad Jafar

Chapter 10 Sections 1,2,9,10 Dr. Iyad Jafar Starting with Serial Chapter 10 Sections 1,2,9,10 Dr. Iyad Jafar Outline Introduction Synchronous Serial Communication Asynchronous Serial Communication Physical Limitations Overview of PIC 16 Series The

More information

Experiment 7:The USART

Experiment 7:The USART University of Jordan Faculty of Engineering and Technology Department of Computer Engineering Embedded Systems Laboratory 0907334 7 Experiment 7:The USART Objectives Introduce the USART module of the PIC

More information

movwf prevcod ; a new button is pressed - rcnt=3 movwf (mtx_buffer+1) movlw 3 movwf rcnt

movwf prevcod ; a new button is pressed - rcnt=3 movwf (mtx_buffer+1) movlw 3 movwf rcnt movlw 0x20 #endif call scan movlw 0xfd tris PORTB ; select colb (RB1) #ifdef MODE_CH8 movlw 0x04 #endif #ifdef MODE_CH4 movlw 0x30 #endif call scan movf cod, W bz loop2 ; if no buton is pressed, skip subwf

More information

PIC16F84A 7.0 INSTRUCTION SET SUMMARY INSTRUCTIONS DESCRIPTIONS

PIC16F84A 7.0 INSTRUCTION SET SUMMARY INSTRUCTIONS DESCRIPTIONS PI6F84A 7.0 INSTRUTION SET SUMMARY Each PI6XX instruction is a 4bit word, divided into an OPODE which specifies the instruction type and one or more operands which further specify the operation of the

More information

ME 6405 Introduction to Mechatronics

ME 6405 Introduction to Mechatronics ME 6405 Introduction to Mechatronics Fall 2006 Instructor: Professor Charles Ume Microchip PIC Manufacturer Information: Company: Website: http://www.microchip.com Reasons for success: Became the hobbyist's

More information

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING. EE6008 Microcontroller based system design

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING. EE6008 Microcontroller based system design Year: IV DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING EE6008 Microcontroller based system design Semester : VII UNIT I Introduction to PIC Microcontroller

More information

Gateway Ascii Command Protocol

Gateway Ascii Command Protocol Gateway Ascii Command Protocol Table Of Contents Introduction....2 Ascii Commands.....3 Messages Received From The Gateway....3 Button Down Message.....3 Button Up Message....3 Button Maintain Message....4

More information

PIC16F87XA Data Sheet

PIC16F87XA Data Sheet M Data Sheet 28/40-pin Enhanced FLASH Microcontrollers 2001 Microchip Technology Inc. Advance Information DS39582A 2001 Microchip Technology Inc. Advance Information DS39582A-page 3 Pin Diagram RB7/PGD

More information

The cache is 4-way set associative, with 4-byte blocks, and 16 total lines

The cache is 4-way set associative, with 4-byte blocks, and 16 total lines Sample Problem 1 Assume the following memory setup: Virtual addresses are 20 bits wide Physical addresses are 15 bits wide The page size if 1KB (2 10 bytes) The TLB is 2-way set associative, with 8 total

More information

Timer2 Interrupts. NDSU Timer2 Interrupts September 20, Background:

Timer2 Interrupts. NDSU Timer2 Interrupts September 20, Background: Background: Timer2 Interrupts The execution time for routines sometimes needs to be set. This chapter loops at several ways to set the sampling rate. Example: Write a routine which increments an 8-bit

More information

Chapter 13. PIC Family Microcontroller

Chapter 13. PIC Family Microcontroller Chapter 13 PIC Family Microcontroller Lesson 15 Instruction Set Most instructions execution Time One instruction cycle If XTAL frequency = 20 MHz, then instruction cycle time is 0.2 s or 200 ns (= 4/20

More information

PIC PROGRAMMING START. The next stage is always the setting up of the PORTS, the symbol used to indicate this and all Processes is a Rectangle.

PIC PROGRAMMING START. The next stage is always the setting up of the PORTS, the symbol used to indicate this and all Processes is a Rectangle. PIC PROGRAMMING You have been introduced to PIC chips and the assembly language used to program them in the past number of lectures. The following is a revision of the ideas and concepts covered to date.

More information

Arithmetic,logic Instruction and Programs

Arithmetic,logic Instruction and Programs Arithmetic,logic Instruction and Programs 1 Define the range of numbers possible in PIC unsigned data Code addition and subtraction instructions for unsigned data Perform addition of BCD Code PIC unsigned

More information

ĐẠI HỌC QUỐC GIA TP.HỒ CHÍ MINH TRƯỜNG ĐẠI HỌC BÁCH KHOA KHOA ĐIỆN-ĐIỆN TỬ BỘ MÔN KỸ THUẬT ĐIỆN TỬ. Embedded System Design

ĐẠI HỌC QUỐC GIA TP.HỒ CHÍ MINH TRƯỜNG ĐẠI HỌC BÁCH KHOA KHOA ĐIỆN-ĐIỆN TỬ BỘ MÔN KỸ THUẬT ĐIỆN TỬ. Embedded System Design ĐẠI HỌC QUỐC GIA TP.HỒ CHÍ MINH TRƯỜNG ĐẠI HỌC BÁCH KHOA KHOA ĐIỆN-ĐIỆN TỬ BỘ MÔN KỸ THUẬT ĐIỆN TỬ Embedded System Design Chapter 7: Peripherals for embedded systems 7.1 Digital parallel input / output

More information

PIC16C432 OTP 8-Bit CMOS MCU with LIN bus Transceiver

PIC16C432 OTP 8-Bit CMOS MCU with LIN bus Transceiver OTP 8-Bit CMOS MCU with LIN bus Transceiver Devices included in this Data Sheet: High Performance RISC CPU: Only 35 instructions to learn All single cycle instructions (200 ns), except for program branches

More information

Section 13. Timer0 HIGHLIGHTS. Timer0. This section of the manual contains the following major topics:

Section 13. Timer0 HIGHLIGHTS. Timer0. This section of the manual contains the following major topics: Section 13. Timer0 HIGHLIGHTS This section of the manual contains the following major topics: 13.1 Introduction... 13-2 13.2 Control Register... 13-3 13.3 Operation... 13-4 13.4 Timer0 Interrupt... 13-5

More information

M PIC16F84A. 18-pinEnhanced FLASH/EEPROM 8-Bit Microcontroller. High Performance RISC CPU Features: Pin Diagrams. Peripheral Features:

M PIC16F84A. 18-pinEnhanced FLASH/EEPROM 8-Bit Microcontroller. High Performance RISC CPU Features: Pin Diagrams. Peripheral Features: M PIC6F84A 8-pinEnhanced FLASH/EEPROM 8-Bit Microcontroller High Performance RISC CPU Features: Pin Diagrams Only 35 single word instructions to learn All instructions single-cycle except for program branches

More information

EECE.3170: Microprocessor Systems Design I Summer 2017 Homework 5 Solution

EECE.3170: Microprocessor Systems Design I Summer 2017 Homework 5 Solution For each of the following complex operations, write a sequence of PIC 16F1829 instructions that performs an equivalent operation. Assume that X, Y, and Z are 16-bit values split into individual bytes as

More information

Learning Objectives:

Learning Objectives: Topic 5.2.1 PIC microcontrollers Learning Objectives: At the end of this topic you will be able to; Recall the architecture of a PIC microcontroller, consisting of CPU, clock, data memory, program memory

More information

CENG-336 Introduction to Embedded Systems Development. Timers

CENG-336 Introduction to Embedded Systems Development. Timers CENG-336 Introduction to Embedded Systems Development Timers Definitions A counter counts (possibly asynchronous) input pulses from an external signal A timer counts pulses of a fixed, known frequency

More information

Outline. Micriprocessor vs Microcontroller Introduction to PIC MCU PIC16F877 Hardware:

Outline. Micriprocessor vs Microcontroller Introduction to PIC MCU PIC16F877 Hardware: HCMIU - DEE Subject: ERTS RISC MCU Architecture PIC16F877 Hardware 1 Outline Micriprocessor vs Microcontroller Introduction to PIC MCU PIC16F877 Hardware: Program Memory Data memory organization: banks,

More information

S w e d i s h c r. w e e b l y. c o m j a l i l a h m e l i v e. c o m Page 1

S w e d i s h c r. w e e b l y. c o m j a l i l a h m e l i v e. c o m Page 1 ********************************************************************** This file is a basic code template for assembly code generation * on the PICmicro PIC12C508. This file contains the basic code * building

More information

Laboratory Exercise 5 - Analog to Digital Conversion

Laboratory Exercise 5 - Analog to Digital Conversion Laboratory Exercise 5 - Analog to Digital Conversion The purpose of this lab is to control the blinking speed of an LED through the Analog to Digital Conversion (ADC) module on PIC16 by varying the input

More information

Application Note - PIC Source Code v1.1.doc

Application Note - PIC Source Code v1.1.doc Programmable, RGB-backlit LCD Keyswitches APPLICATION NOTE PIC SOURCE CODE 2004-2006 copyright [E³] Engstler Elektronik Entwicklung GmbH. All rights reserved. PIC Source Code The following Assembler source

More information

Distributed by: www.jameco.com 1-800-831-4242 The content and copyrights of the attached material are the property of its owner. M PIC16F87XA Data Sheet 28/40-pin Enhanced FLASH Microcontrollers 2001 Microchip

More information

PIC16F8X 18-pin Flash/EEPROM 8-Bit Microcontrollers

PIC16F8X 18-pin Flash/EEPROM 8-Bit Microcontrollers 18-pin Flash/EEPROM 8-Bit Microcontrollers Devices Included in this Data Sheet: PIC16F83 PIC16F84 PIC16CR83 PIC16CR84 Extended voltage range devices available (PIC16LF8X, PIC16LCR8X) High Performance RISC

More information

UNH-IOL MIPI Alliance Test Program

UNH-IOL MIPI Alliance Test Program DSI Receiver Protocol Conformance Test Report UNH-IOL 121 Technology Drive, Suite 2 Durham, NH 03824 +1-603-862-0090 mipilab@iol.unh.edu +1-603-862-0701 Engineer Name engineer@company.com Panel Company

More information

PIC16F8X. 8-Bit CMOS Flash/EEPROM Microcontrollers PIC16F8X PIC16CR8X. Pin Diagram. Devices Included in this Data Sheet:

PIC16F8X. 8-Bit CMOS Flash/EEPROM Microcontrollers PIC16F8X PIC16CR8X. Pin Diagram. Devices Included in this Data Sheet: This document was created with FrameMaker 404 PIC16F8X 8-Bit CMOS Flash/EEPROM Microcontrollers Devices Included in this Data Sheet: PIC16F83 PIC16CR83 PIC16F84 PIC16CR84 Extended voltage range devices

More information

SOLUTIONS!! DO NOT DISTRIBUTE PRIOR TO EXAM!!

SOLUTIONS!! DO NOT DISTRIBUTE PRIOR TO EXAM!! THE UNIVERSITY OF THE WEST INDIES EXAMINATIONS OF APRIL MID-TERM 2005 Code and Name of Course: EE25M Introduction to Microprocessors Paper: MidTerm Date and Time: Thursday April 14th 2005 8AM Duration:

More information

MC68705P3 Bootstrap ROM

MC68705P3 Bootstrap ROM MC68705P3 Bootstrap ROM ;This is a listing of the Bootstrap ROM which resides in Motorola's MC68705P3 single chip ;micros. Its sole purpose is to program its own EPROM by copying the data from an external

More information

Fortune. Semiconductor Corporation 富晶半導體股份有限公司. 8-bit MCU with 1k program ROM, 64-byte RAM, 1 R2F module and 3 13 LCD driver. TD Rev. 1.

Fortune. Semiconductor Corporation 富晶半導體股份有限公司. 8-bit MCU with 1k program ROM, 64-byte RAM, 1 R2F module and 3 13 LCD driver. TD Rev. 1. Fortune 1 R2F module and 3 13 LCD driver. Data Sheet TD-0410001 Rev. 1.2 This manual contains new product information. Fortune reserves the rights to modify the product specification without further notice.

More information

DESIGN AND FABRICATION OF FARE METER OF TAXICAB USING MICROCONTROLLER

DESIGN AND FABRICATION OF FARE METER OF TAXICAB USING MICROCONTROLLER Proceedings of the International Conference on Mechanical Engineering 00 (ICME00) 8-0 December 00, Dhaka, Bangladesh ICME0-AM-0 DESIGN AND FABRICATION OF FARE METER OF TAXICAB USING MICROCONTROLLER Md.

More information

Performance & Applications

Performance & Applications EE25M Introduction to microprocessors original author: Feisal Mohammed updated: 15th March 2002 CLR Part VI Performance & Applications It is possible to predict the execution time of code, on the basis

More information

PIC16F84A. 18-pin Enhanced Flash/EEPROM 8-Bit Microcontroller. Devices Included in this Data Sheet: Pin Diagrams. High Performance RISC CPU Features:

PIC16F84A. 18-pin Enhanced Flash/EEPROM 8-Bit Microcontroller. Devices Included in this Data Sheet: Pin Diagrams. High Performance RISC CPU Features: M PIC6F84A 8-pin Enhanced Flash/EEPROM 8-Bit Microcontroller Devices Included in this Data Sheet: PIC6F84A Extended voltage range device available (PIC6LF84A) High Performance RISC CPU Features: Only 35

More information

Hong Kong Institute of Vocational Education Digital Electronics & Microcontroller. 8. Microcontroller

Hong Kong Institute of Vocational Education Digital Electronics & Microcontroller. 8. Microcontroller 8. Microcontroller Textbook Programming Robot Controllers, Myke Predko, McGraw Hill. Reference PIC Robotics: A Beginner's Guide to Robotics Projects Using the PIC Micro, John Iovine, McGraw Hill. Embedded

More information

NH-67, TRICHY MAIN ROAD, PULIYUR, C.F , KARUR DT. DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING COURSE MATERIAL

NH-67, TRICHY MAIN ROAD, PULIYUR, C.F , KARUR DT. DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING COURSE MATERIAL NH-67, TRICHY MAIN ROAD, PULIYUR, C.F. 639 114, KARUR DT. DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING COURSE MATERIAL Subject Name : Embedded System Class/Sem : BE (ECE) / VII Subject Code

More information

Arithmetic and Logic Instructions. Hsiao-Lung Chan Dept Electrical Engineering Chang Gung University, Taiwan

Arithmetic and Logic Instructions. Hsiao-Lung Chan Dept Electrical Engineering Chang Gung University, Taiwan Arithmetic and Logic Instructions Hsiao-Lung Chan Dept Electrical Engineering Chang Gung University, Taiwan chanhl@mail.cgu.edu.tw Find the sum of the values from 40H to 43H. Put the sum in filereg locations

More information

The University of Texas at Arlington Lecture 5

The University of Texas at Arlington Lecture 5 The University of Texas at Arlington Lecture 5 CSE 3442/5442 LCD Discussed in Chapter 12 RS, R/W, E Signals Are Used to Send/Receive Data on D0-D7 2 PIC PROGRAMMING IN C CHAPTER 7 Chapter 7 discusses the

More information

RS 232 PINOUTS. 1. We use RJ12 for all of our RS232 interfaces (Link-2-Modbus & Link-2-PC- Serial/RS232). The diagram below shows our pin out.

RS 232 PINOUTS. 1. We use RJ12 for all of our RS232 interfaces (Link-2-Modbus & Link-2-PC- Serial/RS232). The diagram below shows our pin out. RS 232 PINOUTS 1. We use RJ12 for all of our RS232 interfaces (Link-2-Modbus & Link-2-PC- Serial/RS232). The diagram below shows our pin out. 2. A DB9 Female to RJ12 Female Serial/Terminal Modular Adaptor

More information

Appendix D: Source Codes. PDF created with pdffactory Pro trial version

Appendix D: Source Codes. PDF created with pdffactory Pro trial version Appendix D: Source Codes Accelerometer Acquisition program (MPLAB) List p=16f877a include "p16f877a.inc" config _cp_off & _wdt_off & _xt_osc & _pwrte_on ;Reading Accelerometer duty cycle value ;This subroutine

More information