ADC hangs during data valiable check

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable
        I'm using a 12 bit ADC attached to pin 01 and I'm communicating with a DS75   
temperature sensor attached to pins on port 1.   
I have to routines:   
The first one reads out the temperature sensor IC and sends the temperature over RS232   
to the computer.   
The seconds reads the 12 bit ADC and sends it also to the computer.   
The problem:   
When I'm just reading out the temperature or the voltage everything works.   
BUT when I first read out the temperature and afterward the voltage the program hangs   
at the "lcall ADCINC12_1_fIsDataAvaliable" command.   
   
Thanks in advance for any help regarding to this problem!!!   
   
The routines:   
   
;============================================================   
; Send Temperature over UART   
;============================================================   
Send_Temp:   
mov [Tmp_Address], 0 //Read Temperature from Device with address 0   
lcall tmp_read //Read it   
mov A, [Temp] //Send it to Computer   
lcall UART_1_PutChar   
mov A, [Temp+1]   
lcall UART_1_PutChar   
ljmp loop //Jump back   
   
;============================================================   
; Send AD-Value over UART   
;============================================================   
Send_AD:   
lcall ADCINC12_1_fIsDataAvaliable // If conversion complete....   
jz Send_AD   
   
lcall ADCINC12_1_ClearFlag   
lcall ADCINC12_1_iGetData // Get result, convert to unsigned and clear flag   
   
mov [iResult+1], A   
mov [iResult+0], X   
add [iResult+0], 0x08 // add 0x0800 to result   
   
mov A, [iResult+1] //Send MSB first   
lcall UART_1_PutChar   
mov A, [iResult+0]   
lcall UART_1_PutChar   
   
ljmp loop   
0 Likes
1 Reply
Anonymous
Not applicable
        Found the problem myself!   
   
I was using a shifting register in the tmp_read routine.   
Instead of clearing the carry flag like   
   
and F, 0xFB   
   
I did "and F, 0x00".   
   
Problem solved 😉   
0 Likes