Diagnostic Program

Discussion in 'Embedded Systems and Microcontrollers' started by PIC GUY TREVOR, Mar 10, 2009.

  1. PIC GUY TREVOR

    Thread Starter Member

    Mar 8, 2009
    28
    0
    Hi All

    I am having trouble designing a diagnostic program that checks all the output ports on my pic16F84A whch is controlling my prototype board.

    Thanks
     
  2. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    What is the program?

    Turn 13 LEDs on, then Off, something more advanced?
     
  3. PIC GUY TREVOR

    Thread Starter Member

    Mar 8, 2009
    28
    0
    I am building from scratch using MPLab as the compiler, yes just to turn on 8 leds, its an 18 pinchip
     
  4. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    This is will flash LEDs alternating on both ports, Swap out instructions/ports for assembly/C code for your uC.

    Here is the code as compiled by BoostC, showing the assembly output. Note: This will not directly assemble, as I left out the delay code.

    Code ( (Unknown Language)):
    1.  
    2. void main()
    3.  
    4. {
    5.  
    6.     trisa=0;  // porta all output
    7. 002F  1683      BSF STATUS, RP0
    8. 0030  1303      BCF STATUS, RP1
    9. 0031  0185      CLRF gbl_trisa
    10.  
    11.     trisb=0;  // portb all output
    12. 0032  0186      CLRF gbl_trisb
    13.  
    14.     porta=0xAA; // 10101010
    15. 0033  30AA      MOVLW 0xAA
    16. 0034  1283      BCF STATUS, RP0
    17. 0035  0085      MOVWF gbl_porta
    18.  
    19.     portb=0xAA;
    20. 0036  0086      MOVWF gbl_portb
    21.  
    22.    
    23. while (1)
    24. 0037        label3
    25. 0041  2837      GOTO    label3
    26.  
    27. {
    28. porta^=0xFF;  // Invert 8 bits
    29. 0037  30FF      MOVLW 0xFF
    30. 0038  0685      XORWF gbl_porta, F
    31.  
    32. delay_ms(50);
    33. 0039  3032      MOVLW 0x32
    34. 003A  00A0      MOVWF delay_ms_00000_arg_del
    35. 003B  2003      CALL delay_ms_00000
    36.  
    37. portb^=0xFF;  // Invert 8 bits
    38. 003C  30FF      MOVLW 0xFF
    39. 003D  0686      XORWF gbl_portb, F
    40.  
    41. delay_ms(50);  
    42. 003E  3032      MOVLW 0x32
    43. 003F  00A0      MOVWF delay_ms_00000_arg_del
    44. 0040  2003      CALL delay_ms_00000
    45.  
    46. }
    47. }
    48.  
     
  5. PIC GUY TREVOR

    Thread Starter Member

    Mar 8, 2009
    28
    0
    Thanks I wiil give it a try
     
Loading...