Share Pastebin
Guest
Public paste!

solarwind

By: a guest | Jan 21st, 2009 | Syntax: None | Size: 1.56 KB | Hits: 194 | Expires: Never
Copy text to clipboard
  1. #include <p16F690.inc>
  2.      __config (_INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _BOR_OFF & _IESO_OFF & _FCMEN_OFF)
  3.  
  4.      cblock 0x20
  5. Delay1              ; Assign an address to label Delay1
  6. Delay2
  7. Display             ; define a variable to hold the diplay
  8.      endc
  9.          
  10.      org 0
  11. Start:
  12.      bsf       STATUS,RP0     ; select Register Page 1
  13.      movlw     0xFF
  14.      movwf     TRISA          ; Make PortA all input
  15.      clrf      TRISC          ; Make PortC all output
  16.      movlw     0x10           ; A2D Clock Fosc/8
  17.      movwf     ADCON1
  18.      bcf       STATUS,RP0     ; back to Register Page 0
  19.  
  20.      bcf       STATUS,RP0     ; address Register Page 2
  21.      bsf       STATUS,RP1    
  22.      movlw     0xFF           ; we want all Port A pins Analoga
  23.      movwf     ANSEL
  24.      bcf       STATUS,RP0     ; address Register Page 0
  25.      bcf       STATUS,RP1
  26.      
  27.      movlw     0x01
  28.      movwf     ADCON0         ; configure A2D for Channel 0 (RA0), Left justified, and turn on the A2D module
  29. MainLoop:
  30.      nop                      ; wait 5uS for A2D amp to settle and capacitor to charge.
  31.      nop                      ; wait 1uS
  32.      nop                      ; wait 1uS
  33.      nop                      ; wait 1uS
  34.      nop                      ; wait 1uS
  35.      bsf       ADCON0,GO      ; start conversion
  36.      btfss     ADCON0,GO      ; this bit will change to zero when the conversion is complete
  37.      goto      $-1
  38.  
  39.      swapf     ADRESH,w       ; Copy the display to the LEDs
  40.      movwf     PORTC
  41.      goto      MainLoop
  42.      end