Advertisement
Advertisement
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
|
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: |
#include <p16F877a.inc>
LIST p=16F877a
errorlevel 1,-302 ;to disable MPLAB bank warnings.
__config _XT_OSC & _PWRTE_ON & _WDT_OFF &_LVP_OFF
;
;Some versions of MPLAB use _LVP_OFF
;This sets all portB pins to output.
;Variables
cblock 0x20 ;start of general purpose registers
COUNT
TEMP
CYC
endc
;/*---------Init Ports
bsf STATUS,RP0
MOVLW B'00000001'
MOVWF TRISA ;All outputs except RA0.
MOVLW B'00000011'
movwf TRISE
CLRF TRISB ;PortB is 8 LED output to show
movlw b'11111111'
movwf TRISD
;/*-----Set up A2D parameters
MOVLW B'00001110'
MOVWF ADCON1
MOVLW B'11010111'
MOVWF OPTION_REG
BCF STATUS,RP0
;/*---------Set up chip parameters
Start CALL A2D
MOVWF TEMP
MOVWF PORTB ;output Hex value to LEDs
PC
BTFSC PORTE,0
goto Start
;TEMP <= 80
movf TEMP,w
addlw d'255'-d'80'
skpnc
Call HeatIndex
;TEMP <= 40
movf TEMP,w
addlw d'255'-d'40'
skpc
Call WindChill
GOTO Start
A2D
MOVLW B'01000001' ;a2d = on, ch0, fosc/8
MOVWF ADCON0
;/*-----Delay loop to settle A2D, similar to de-bounce???
mnloop btfss INTCON,T0IF ;50us loop delay @ 4Mhz
goto mnloop
;/*-----Stop timer0 interrupt
BCF INTCON,T0IF
BSF ADCON0,GO_DONE ;start a2d conversion
WAITA2D NOP ;wait 4 finish
BTFSC ADCON0,GO_DONE
GOTO WAITA2D
;/*-----Put A2D W and send to port B.
MOVF ADRESH,W ;upper 8 bits-ignor lower 3
RETURN
HeatIndex
START MOVLW d'10'
MOVWF CYC
CLRF COUNT
L1 BTFSS PORTC,2
GOTO L1
L2 INCF COUNT
BTFSC PORTC,2
GOTO L2
DECFSZ CYC
GOTO L1
MOVF COUNT,w
MOVWF PORTB
BTFSS PORTE,0
GOTO HeatIndex
RETURN
WindChill
movf PORTD,w
movwf PORTB
BTFSS PORTE,0
GOTO WindChill
RETURN
END
|