Problem with PIC Code of Path Learning Car

Discussion in 'Embedded Systems and Microcontrollers' started by hunzaboy, May 4, 2010.

  1. hunzaboy

    Thread Starter New Member

    May 4, 2010
    3
    0
    Hello there!

    I need help regarding my project. I have designed the Hardware completely. I am designing a path learning car.

    However i am having trouble with the code. I am using PIC16F877 mc. the code is attached.

    MY PROBLEMS: When i am trying to send an interrupt to pin RB0 then no pulse is detected. which means no interrupt. I want to know the problem. Can anyone help me?

    Code ( (Unknown Language)):
    1.  
    2.         list      p=16f877            ; list directive to define processor
    3.         #include <p16f877.inc>        ; processor specific variable definitions
    4.        
    5.         __CONFIG _CP_OFF & _WDT_OFF & _BODEN_ON & _PWRTE_ON & _XT_OSC & _WRT_ENABLE_ON & _LVP_ON & _DEBUG_OFF & _CPD_OFF
    6.    
    7.     ; '__CONFIG' directive is used to embed configuration data within .asm file.
    8.     ; The lables following the directive are located in the respective .inc file.
    9.     ; See respective data sheet for additional information on configuration word.
    10.    
    11.    
    12.    
    13.    
    14.    
    15.    
    16.     ;***** VARIABLE DEFINITIONS
    17.    
    18. CHECK EQU 0X20
    19. TEMP EQU 0X21
    20. A1 EQU 0X022
    21. B1 EQU 0X023
    22. C1 EQU 0X024
    23.    
    24.    
    25.    
    26.    
    27.    
    28.     ;**********************************************************************
    29.     ORG     0x000             ; processor reset vector
    30.     clrf    PCLATH            ; ensure page bits are cleared
    31.     GOTO    MAIN              ; go to beginning of program
    32.    
    33.    
    34.     ORG     0x004             ; interrupt vector location
    35.     MOVF CHECK,0
    36.     XORLW D'1'
    37.     MOVWF CHECK
    38.    
    39.     MOVLW b'10000000'
    40.     MOVWF PORTD
    41.     ; clearing in software
    42.     BCF INTCON,1;
    43.     RETFIE
    44.    
    45.    
    46.    
    47.    
    48. MAIN
    49.    
    50.  
    51.     MOVLW B'10100101';
    52.     MOVWF TEMP;
    53.     MOVLW D'1';
    54.     MOVWF CHECK;
    55.  
    56.    
    57.     ;;;;;;;;;;;;;;;PORTS
    58.     BANKSEL TRISC
    59.     MOVLW B'00000000'
    60.     MOVWF TRISC
    61.    
    62.     BANKSEL TRISB
    63.    
    64.     MOVLW B'11111111'
    65.     MOVWF TRISB
    66.  
    67.    
    68.     BANKSEL INTCON
    69.    
    70.    
    71.     ;;;On Interrupts
    72.     BCF INTCON,1;
    73.     BSF INTCON,4;
    74.     BSF INTCON, 6;
    75.     BSF INTCON, 7;
    76.     BSF INTCON, 3;
    77.     ;; stop the car
    78.  
    79. LOOP
    80.     ;;;;;;;;;;;;;;;;;;;;;;
    81.     MOVF CHECK,0
    82.     XORLW D'1'
    83.     BTFSS STATUS,Z;
    84.     GOTO LOOP1
    85.    
    86.    
    87. ;; START CAR ( any pin on port C)
    88.     MOVLW B'11111111'
    89.     MOVWF PORTC;
    90. ;    CALL DELAY1
    91.  
    92.     GOTO LOOP
    93.    
    94. LOOP1
    95.    
    96.     MOVF CHECK,0
    97.     XORLW D'1'
    98.     BTFSC STATUS,Z;
    99.     GOTO LOOP
    100.  
    101.     BANKSEL PORTC
    102.     MOVLW B'00000000'
    103.     MOVWF PORTC;
    104.     GOTO LOOP1
    105.     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    106.  
    107.     END
    108.  
     
  2. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
  3. BMorse

    Senior Member

    Sep 26, 2009
    2,675
    234
    post the circuit also, so we know how you have things wired up and connected, since I see you have Low voltage Programming enabled and all......depending on how you have this connected in the circuit, the pic may not even start up at all....


    B. Morse
     
  4. hunzaboy

    Thread Starter New Member

    May 4, 2010
    3
    0
    No the PIC has started. Because the code which is burnt default by myself works fine. But when i give interrupt then its not working.
    However my code works properly in PROTEUS but not working on Hardware..
     
  5. BMorse

    Senior Member

    Sep 26, 2009
    2,675
    234

    How did you determine the PIC starts fine? Do you have another routine that test something to determine that? Simulating circuits to me is like making a lot of assumptions ( that are usually wrong).... better to have built the circuit on a breadboard than to simulate it....

    B. Morse
     
  6. hunzaboy

    Thread Starter New Member

    May 4, 2010
    3
    0
    Yeah i have worked on breadboard. The PIC is working fine on the HARDWARE. i have check it with other sample codes. And also in the given code the initial output of "binary 1s" is coming.
     
  7. MMcLaren

    Well-Known Member

    Feb 14, 2010
    759
    116
    Can you use actual bit names in operands (for INTCON for example) or perhaps add a comment or two? We shouldn't have to do this for you since you're the one asking for help.

    If you are using interrupts then your interrupt handler is deficient...

    Regards, Mike
     
Loading...