PIC16F88 led flasher not working

Discussion in 'Programmer's Corner' started by Dodgydave, Jun 29, 2012.

  1. Dodgydave

    Thread Starter Distinguished Member

    Jun 22, 2012
    4,980
    744
    Can some one help me solve this as i am banging my head ,its just a simple 1hz led flasher on pin RA0,

    i have built the asm file, programmed it and put the pic in the circuit board, all that happens is all the pins are at 2v op,with 2.6v ac signal , except the supply pins at 5volts .

    Is there some thing in the programme i have done wrong or are my pics faulty?? :mad:

    ;This is to flash an led on pin ra0 at 1hz



    LIST p=16F88 ;tell assembler what chip we are using
    #include <P16F88.inc> ;include the defaults for the chip
    ;set up config register

    __CONFIG _CONFIG1, _CP_OFF & _CCP1_RB0 & _DEBUG_OFF & _WRT_PROTECT_OFF & _CPD_OFF & _LVP_OFF & _BODEN_OFF & _MCLR_OFF & _PWRTE_ON & _WDT_OFF & _INTRC_IO
    __CONFIG _CONFIG2, _IESO_OFF & _FCMEN_OFF

    org 0x0000 ;org sets the origin, 0x0000 for the 16F88,
    ;this is where the program starts running
    goto Loop

    cblock 0x20
    d1
    d2
    d3
    endc
    bsf STATUS, RP0 ;select bank 1
    movlw b'01110110' ;set osc to 8mhz
    movwf OSCCON
    movlw b'11000110' ;set up prescaler to 128 on Tmr0
    movwf OPTION_REG

    movlw b'00000000' ;set PortA all outputs
    movwf TRISA
    movlw b'11111111'
    movwf TRISB ;set PortB all inputs
    bcf STATUS, RP0 ;select bank 0
    clrf PORTA ;clear portA
    clrf PORTB

    Loop
    bsf PORTA,0
    ;set bit 0 on
    call Delay
    ;
    bcf PORTA,0
    call Delay ;set bit0 off
    goto Loop ;go back and do it again
    Delay

    ;delay of 500msec at 8mhz clock
    ;999997 cycles
    movlw 0x08
    movwf d1
    movlw 0x2F
    movwf d2
    movlw 0x03
    movwf d3
    Delay_0
    decfsz d1, f
    goto $+2
    decfsz d2, f
    goto $+2
    decfsz d3, f
    goto Delay_0
    ;3 cycles
    goto $+1
    nop

    return
    end
     
  2. JohnInTX

    Moderator

    Jun 26, 2012
    2,345
    1,025
    You need to write 00h to ANSEL to make it a digital port.
    From 5.1 in the data book:


    Code ( (Unknown Language)):
    1. BANKSEL ANSEL ; Select Bank of ANSEL
    2. MOVLW 0x00 ; Configure all pins
    3. MOVWF ANSEL ; as digital inputs
    4.  
     
  3. Dodgydave

    Thread Starter Distinguished Member

    Jun 22, 2012
    4,980
    744
    Even this simple bit wont work, all it does it put led on portB 4& 5

    all i get is 2v dc on the pins except the supply which is at 5v.


    LIST p=16F88 ; list directive to define processor
    #INCLUDE <P16F88.INC> ; processor specific variable definitions
    ;------------------------------------------------------------------------------
    ;
    ; CONFIGURATION WORD SETUP
    ;
    ; The 'CONFIG' directive is used to embed the configuration word within the
    ; .asm file. The lables following the directive are located in the respective
    ; .inc file. See the data sheet for additional information on configuration
    ; word settings.
    ;
    ;------------------------------------------------------------------------------
    __CONFIG _CONFIG1, _CP_OFF & _CCP1_RB0 & _DEBUG_OFF & _WRT_PROTECT_OFF & _CPD_OFF & _LVP_OFF & _BODEN_OFF & _MCLR_ON & _PWRTE_ON & _WDT_OFF & _INTRC_IO
    __CONFIG _CONFIG2, _IESO_OFF & _FCMEN_OFF
    ;------------------------------------------------------------------------------
    ;

    RESET ORG 0x0000 ; processor reset vector
    PAGESEL START
    GOTO START ; go to beginning of program

    bsf STATUS, RP0 ;select bank 1


    movlw 0x0
    movwf TRISB ;set PortB all outputs
    bcf STATUS, RP0 ;select bank 0

    ;------------------------------------------------------------------------------
    ; USER INTERRUPT SERVICE ROUTINE GOES HERE
    ;------------------------------------------------------------------------------

    ;------------------------------------------------------------------------------
    ; MAIN PROGRAM
    ;------------------------------------------------------------------------------
    START

    bsf PORTB,4
    bsf PORTB,5
    END
     
  4. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    You need a loop to stop the processor from continuing to run through the rest of program memory, which may be blank, or contain part of a previous program. After a short period it will probably be back at the start of program memory again. The END statement does not stop the processor.
     
  5. Dodgydave

    Thread Starter Distinguished Member

    Jun 22, 2012
    4,980
    744
    I cant even get an output to go high on any port A or B so what is wrong in the setup??
     
  6. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    This one has MCLR_ON, have you put a 10K resistor from the MCLR pin to 5V?
     
  7. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    I don't think you have mentioned what type of programmer you are using. Some may require you to put the configuration in the uploading program. If you are programming by ICSP then the default setting may be to hold the device in reset. A picture of the setup might help us find the problem.
     
  8. Dodgydave

    Thread Starter Distinguished Member

    Jun 22, 2012
    4,980
    744
    I am using a pickit2, and have never used it before so i dont even know if its working correctly, if you have an asm file that i can try for the 16f88 , just to make an led come on, any port will do so i can see if its the programmer,
    as i'm loosing the will to live!!
     
  9. MrChips

    Moderator

    Oct 2, 2009
    12,440
    3,361
    As Markd77 says, you have to pullup the MCLR pin.
    Can you post a circuit schematic?
     
  10. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    If it says "verified OK" or something like that then it's working fine.
    I haven't got any F88 test files.
    How are you connecting the programmer and powering the PIC?
    I'd suggest for now, programming, then removing the programmer and powering the PIC with a decent power supply. 3 AA batteries is a good supply.
    I'm going to be unavailable for a couple of hours.
     
  11. Dodgydave

    Thread Starter Distinguished Member

    Jun 22, 2012
    4,980
    744
    I have fixed the problem, it was the pics, so binned them, and gone onto the 16f628a and all is well and flashing ...
     
    Last edited: Jun 30, 2012
Loading...