urgent..please help am stuck

Discussion in 'Embedded Systems and Microcontrollers' started by ali shaheen, Oct 7, 2010.

  1. ali shaheen

    Thread Starter New Member

    Jan 24, 2009
    3
    0
    hello

    i had made the JDM programmer by my self:),I got the schematic of that from the below given link

    http://www.circuit-projects.com/microcontroller/pic-and-eeprom-programmer.html

    I am using MPLAB for programming and PICpgm for burning the PIC18f452 microcontroller.

    i am using 10mhz crystal osc with 22pf of parallel capacitors...a 5v power supply driven from a 9v battery and then lm7805....my basic code for only flashing the led from portB is given below

    ;;SIMPLE led FLASHER
    ;;USING BIT SET AND BIT CLEAR ((BSF,,BCF)...
    #INCLUDE<P18F452.INC>
    ORG 100H


    V1 EQU 25H;
    V2 EQU 35H;
    R2 EQU 15H;
    R3 EQU 20H;
    R4 EQU 22H;

    LOOP
    CLRF TRISB;
    BSF PORTB,0;
    CALL DELAY;
    BSF PORTB,1;
    CALL DELAY;
    BSF PORTB,2;
    CALL DELAY;
    BSF PORTB,3;
    CALL DELAY;
    BSF PORTB,4;
    CALL DELAY;
    BSF PORTB,5;
    CALL DELAY;
    BSF PORTB,6;
    CALL DELAY;
    BCF PORTB,5
    CALL DELAY;
    BCF PORTB,4
    CALL DELAY;
    BCF PORTB,3
    CALL DELAY;
    BCF PORTB,2
    CALL DELAY;
    BCF PORTB,1
    CALL DELAY;
    BCF PORTB,0
    CALL DELAY;

    GOTO LOOP;
    DELAY
    ;DELAY 20*100*250*5*400ns=1,000,000,000 ns = 1,000,000 us = 1s
    MOVLW D'20';
    MOVWF R4;
    BACK MOVLW D'100';
    MOVWF R3
    AGAIN MOVLW D'250'
    MOVWF R2
    THERE NOP
    NOP
    DECF R2,F
    BNZ THERE
    DECF R3,F
    BNZ AGAIN
    DECF R4,F
    BNZ BACK
    RETURN


    END


    the problem I am getting is that the LEDs are not flashing as i want them to...instead they are not turning on either..:confused:.from any of the ports....in configuration bits i had disabled watchdog timer,used HS osc type,.

    please let me know what is the problem with it...either its the programmer or the code.......plaese please help me......am really in a hell lot of trouble.:(

    best regards
    ali shaheen
     
  2. ali shaheen

    Thread Starter New Member

    Jan 24, 2009
    3
    0
  3. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    This is from the datasheet, might be worth a try. Just put clrf TRISB instead of the last 2 instructions.
    Code ( (Unknown Language)):
    1. CLRF PORTB ; Initialize PORTB by
    2. ; clearing output
    3. ; data latches
    4. CLRF LATB ; Alternate method
    5. ; to clear output
    6. ; data latches
    7. MOVLW 0xCF ; Value used to
    8. ; initialize data
    9. ; direction
    10. MOVWF TRISB ; Set RB<3:0> as inputs
    11. ; RB<5:4> as outputs
    12. ; RB<7:6> as inputs
     
  4. ali shaheen

    Thread Starter New Member

    Jan 24, 2009
    3
    0
    hello MARKD77

    well thankyou very much for your quick reply but i cldnt understand wht u are trying to say......am a bit confused that which last two instruction u are talking about

    best regard
    ali shaheen
     
  5. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    Try putting this in your code instead of just CLRF TRISB. It's probably better to put it before your LOOP as well.
    Code ( (Unknown Language)):
    1. CLRF PORTB
    2. CLRF LATB
    3. CLRF TRISB
     
  6. wannaBinventor

    Member

    Apr 8, 2010
    179
    4
    Code ( (Unknown Language)):
    1.  
    2. GOTO LOOP;
    3. DELAY
    4. ;DELAY 20*100*250*5*400ns=1,000,000,000 ns = 1,000,000 us = 1s
    5. MOVLW D'20';
    6. MOVWF R4;
    7. BACK MOVLW D'100';
    8. MOVWF R3
    9. AGAIN MOVLW D'250'
    10. MOVWF R2
    11. THERE NOP
    12. NOP
    13. DECF R2,F
    14. BNZ THERE
    15. DECF R3,F
    16. BNZ AGAIN
    17. DECF R4,F
    18. BNZ BACK
    19. RETURN
    20.  
    I'm not familiar with the 18F pics, but I think the branch on non zero is missing you up. If the bnz command is sending you back to your label (the GOTO portion of bnz), then you are reloading the registers R3 and R2 (maybe more) with your literal value. I'm not up on the bnz command, but just a thought.
     
  7. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    I can see any setting of the configuration word (data sheet cap 19.0 SPECIAL FEATURES OF THE CPU). If the configuration word is not correct set, your MCU will not work. Also the JDM programmer is well known to be unpredictable. Are you able to verify that your code is programmed correct into the MCU?
     
  8. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    Any luck yet?
    Also where are you based? Maybe there is a member near you that can check if the PIC is getting programmed.
     
Loading...