• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC16F818

    Blog entry posted in 'Programming a PIC16F818', September 15, 2015.

    Dear Sir,



    I have a Microchip Technology PIC16F818 that I would like to program. For right now I only want to make RA4 (PIN 3) go high and light an LED.



    I have a unique situation in this DIY world and that is that I have made my own device to output the programming bits. Perhaps before we explore the output bit device, you could look over the assembly code and determine if that looks good so far.



    To start off I made DATA RB7 (PIN # 13) low

    CLOCK RB6 (PIN #12) low

    MCLR (PIN #4) zero

    VDD (PIN # 14) low



    Then I made VDD +5 volts and within 200 µ Seconds

    I make MCLR +13 volts. This should place the micro controller in programming mode.



    Next I increment the program counter address (command %00110 in binary) so that the PC is now at 0X05. This is where the program code begins above the interupt vectors.



    Next is the begin erase command (%01000), pause 2 milliseconds and then I issue an end programming command (%10111). These codes are per Table 2-1 on page 7 of the Flash Memory Programming Specification.



    Now I output the following codes LSB first, zero start bit and zero stop bit:



    Assembly Code

    PIC16F818


    BCF 0X03, %111 ;STATUS Register indirect address bit 7 → 0

    BCF 0X03, %110 ;STATUS Register direct address bit 6 → 0

    BSF 0X03, %101 ;STATUS Register direct address bit 5 → 1

    MOVLW 0XEF ;Selecting PIN #3



    I now issue a begin programming command (%11000), wait 2 milli-seconds and issue an end programming command (%10111)



    MOVWF 0X05 ;With bit 5 of the status register a “1” this should

    ;send 0XEF to 0X85 which is the TRISA register, leaving RA4

    ;(PIN 3) a zero which is an output direction.

    BCF 0X03, %101 ;Clear bit 5 of the STATUS Register

    MOVLW 0X10 ;This is setting a “1” in position #4

    MOVWF 0X05 ;This sets a “1” in PORTA (PIN #3)



    Begin programming, wait 2 milli-seconds and end programming

    to send the data to FLASH.



    Now MCLR (PIN #4) is set to zero to reset the PC. DATA & CLOCK are set to zero and +5Volts to VDD on Pin #14 is turned off.



    Now +5 volts to VDD is on and within 200 µ Seconds 13 volts is applied to MCLR PIN #4. We are now in programming mode again.



    Next I increment the program counter address (command %00110 in binary) so that the PC is now at 0X05. This is where the program code begins above the interrupt vectors.



    The +13 volts on MCLR is reduced to 5 volts so that operation can return to normal. This is the point where I expect it to work.



    Needless to say, it does not work. What did I leave out?

    Comments
 

EE World Online Articles

Loading

 
Top