Mercurial > public > hwos_code
comparison src/adc_lightsensor.asm @ 187:669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
Ignore 1,2mV noise for not-connected inputs
author | heinrichsweikamp |
---|---|
date | Sat, 25 Oct 2014 15:28:18 +0200 |
parents | 683321c09cfa |
children | e79bc535ef9e |
comparison
equal
deleted
inserted
replaced
186:a004b482604a | 187:669b5d00706d |
---|---|
322 bcf STATUS,C | 322 bcf STATUS,C |
323 rrcf ADRESH,F ; /2 | 323 rrcf ADRESH,F ; /2 |
324 rrcf ADRESL,F | 324 rrcf ADRESL,F |
325 movff ADRESL,o2_mv_sensor1+0 ; in 0.1mV steps | 325 movff ADRESL,o2_mv_sensor1+0 ; in 0.1mV steps |
326 movff ADRESH,o2_mv_sensor1+1 | 326 movff ADRESH,o2_mv_sensor1+1 |
327 bcf STATUS,C | 327 ; Ignore 1,2mV noise for not-connected inputs |
328 rlcf ADRESL,F | 328 tstfsz o2_mv_sensor1+1 ; >25,5mV? |
329 rlcf ADRESH,F | 329 bra get_analog_inputs2 ; Yes, skip here |
330 movlw b'00100000' ; 2.048V Vref+ | 330 movlw .12 |
331 movwf ADCON1 | 331 cpfsgt o2_mv_sensor1+0 ; >1,2mV? |
332 clrf o2_mv_sensor1+0 ; no, clear result | |
333 get_analog_inputs2: | |
332 movlw b'00100101' ; power on ADC, select AN9 | 334 movlw b'00100101' ; power on ADC, select AN9 |
333 rcall wait_adc | 335 rcall wait_adc |
334 bcf STATUS,C | 336 bcf STATUS,C |
335 rrcf ADRESH,F ; /2 | 337 rrcf ADRESH,F ; /2 |
336 rrcf ADRESL,F | 338 rrcf ADRESL,F |
337 movff ADRESL,o2_mv_sensor2+0 ; in 0.1mV steps | 339 movff ADRESL,o2_mv_sensor2+0 ; in 0.1mV steps |
338 movff ADRESH,o2_mv_sensor2+1 | 340 movff ADRESH,o2_mv_sensor2+1 |
339 movlw b'00100000' ; 2.048V Vref+ | 341 ; Ignore 1,2mV noise for not-connected inputs |
340 movwf ADCON1 | 342 tstfsz o2_mv_sensor2+1 ; >25,5mV? |
343 bra get_analog_inputs3 ; Yes, skip here | |
344 movlw .12 | |
345 cpfsgt o2_mv_sensor2+0 ; >1,2mV? | |
346 clrf o2_mv_sensor2+0 ; no, clear result | |
347 get_analog_inputs3: | |
341 movlw b'00101001' ; power on ADC, select AN10 | 348 movlw b'00101001' ; power on ADC, select AN10 |
342 rcall wait_adc | 349 rcall wait_adc |
343 bcf STATUS,C | 350 bcf STATUS,C |
344 rrcf ADRESH,F ; /2 | 351 rrcf ADRESH,F ; /2 |
345 rrcf ADRESL,F | 352 rrcf ADRESL,F |
346 movff ADRESL,o2_mv_sensor3+0 ; in 0.1mV steps | 353 movff ADRESL,o2_mv_sensor3+0 ; in 0.1mV steps |
347 movff ADRESH,o2_mv_sensor3+1 | 354 movff ADRESH,o2_mv_sensor3+1 |
355 ; Ignore 1,2mV noise for not-connected inputs | |
356 tstfsz o2_mv_sensor3+1 ; >25,5mV? | |
357 bra get_analog_inputs4 ; Yes, skip here | |
358 movlw .12 | |
359 cpfsgt o2_mv_sensor3+0 ; >1,2mV? | |
360 clrf o2_mv_sensor3+0 ; no, clear result | |
361 get_analog_inputs4: | |
348 bcf ADCON0,0 ; power off ADC | 362 bcf ADCON0,0 ; power off ADC |
349 bcf adc_running ; =1: The ADC is in use | 363 bcf adc_running ; =1: The ADC is in use |
350 return | 364 return |
351 | 365 |
352 global piezo_config ; Sets up piezo sensitivity of heinrichs weikamp Piezo buttons (~30ms) | 366 global piezo_config ; Sets up piezo sensitivity of heinrichs weikamp Piezo buttons (~30ms) |