Mercurial > public > hwos_code
comparison src/adc_lightsensor.asm @ 189:e79bc535ef9e
ignore un-calibrated sensors even if they become valid
author | heinrichsweikamp |
---|---|
date | Wed, 29 Oct 2014 12:53:01 +0100 |
parents | 669b5d00706d |
children | a0e0ddfc1b49 |
comparison
equal
deleted
inserted
replaced
188:ebc28381f17d | 189:e79bc535ef9e |
---|---|
319 movwf ADCON1 | 319 movwf ADCON1 |
320 movlw b'00100001' ; power on ADC, select AN8 | 320 movlw b'00100001' ; power on ADC, select AN8 |
321 rcall wait_adc | 321 rcall wait_adc |
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,W |
325 movff ADRESL,o2_mv_sensor1+0 ; in 0.1mV steps | 325 ; add to o2_mv_sensor1:2 |
326 movff ADRESH,o2_mv_sensor1+1 | 326 addwf o2_mv_sensor1+0,F |
327 movf ADRESH,W | |
328 addwfc o2_mv_sensor1+1,F | |
329 ; Devide by 2 | |
330 bcf STATUS,C | |
331 rrcf o2_mv_sensor1+1,F ; /2 | |
332 rrcf o2_mv_sensor1+0,F | |
327 ; Ignore 1,2mV noise for not-connected inputs | 333 ; Ignore 1,2mV noise for not-connected inputs |
328 tstfsz o2_mv_sensor1+1 ; >25,5mV? | 334 tstfsz o2_mv_sensor1+1 ; >25,5mV? |
329 bra get_analog_inputs2 ; Yes, skip here | 335 bra get_analog_inputs2 ; Yes, skip here |
330 movlw .12 | 336 movlw .12 |
331 cpfsgt o2_mv_sensor1+0 ; >1,2mV? | 337 cpfsgt o2_mv_sensor1+0 ; >1,2mV? |
333 get_analog_inputs2: | 339 get_analog_inputs2: |
334 movlw b'00100101' ; power on ADC, select AN9 | 340 movlw b'00100101' ; power on ADC, select AN9 |
335 rcall wait_adc | 341 rcall wait_adc |
336 bcf STATUS,C | 342 bcf STATUS,C |
337 rrcf ADRESH,F ; /2 | 343 rrcf ADRESH,F ; /2 |
338 rrcf ADRESL,F | 344 rrcf ADRESL,W |
339 movff ADRESL,o2_mv_sensor2+0 ; in 0.1mV steps | 345 ; add to o2_mv_sensor2:2 |
340 movff ADRESH,o2_mv_sensor2+1 | 346 addwf o2_mv_sensor2+0,F |
347 movf ADRESH,W | |
348 addwfc o2_mv_sensor2+1,F | |
349 ; Devide by 2 | |
350 bcf STATUS,C | |
351 rrcf o2_mv_sensor2+1,F ; /2 | |
352 rrcf o2_mv_sensor2+0,F | |
341 ; Ignore 1,2mV noise for not-connected inputs | 353 ; Ignore 1,2mV noise for not-connected inputs |
342 tstfsz o2_mv_sensor2+1 ; >25,5mV? | 354 tstfsz o2_mv_sensor2+1 ; >25,5mV? |
343 bra get_analog_inputs3 ; Yes, skip here | 355 bra get_analog_inputs3 ; Yes, skip here |
344 movlw .12 | 356 movlw .12 |
345 cpfsgt o2_mv_sensor2+0 ; >1,2mV? | 357 cpfsgt o2_mv_sensor2+0 ; >1,2mV? |
347 get_analog_inputs3: | 359 get_analog_inputs3: |
348 movlw b'00101001' ; power on ADC, select AN10 | 360 movlw b'00101001' ; power on ADC, select AN10 |
349 rcall wait_adc | 361 rcall wait_adc |
350 bcf STATUS,C | 362 bcf STATUS,C |
351 rrcf ADRESH,F ; /2 | 363 rrcf ADRESH,F ; /2 |
352 rrcf ADRESL,F | 364 rrcf ADRESL,W |
353 movff ADRESL,o2_mv_sensor3+0 ; in 0.1mV steps | 365 ; add to o2_mv_sensor3:2 |
354 movff ADRESH,o2_mv_sensor3+1 | 366 addwf o2_mv_sensor3+0,F |
367 movf ADRESH,W | |
368 addwfc o2_mv_sensor3+1,F | |
369 ; Devide by 2 | |
370 bcf STATUS,C | |
371 rrcf o2_mv_sensor3+1,F ; /2 | |
372 rrcf o2_mv_sensor3+0,F | |
355 ; Ignore 1,2mV noise for not-connected inputs | 373 ; Ignore 1,2mV noise for not-connected inputs |
356 tstfsz o2_mv_sensor3+1 ; >25,5mV? | 374 tstfsz o2_mv_sensor3+1 ; >25,5mV? |
357 bra get_analog_inputs4 ; Yes, skip here | 375 bra get_analog_inputs4 ; Yes, skip here |
358 movlw .12 | 376 movlw .12 |
359 cpfsgt o2_mv_sensor3+0 ; >1,2mV? | 377 cpfsgt o2_mv_sensor3+0 ; >1,2mV? |