Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
01/03/06 13:26
Read: times


 
#106411 - Try this
Responding to: ???'s previous message
Have a look at page 7 of datasheet: In the table you will find "tPD propagation delay time, output data after clock 0 to 1 transition". This means, that data is valid after 0 to 1 transition. But your code reads the data after 1 to 0 transition!

This subroutine should work:

READ_ADC:
 
         MOV TEMP,#08H      ;set the loop variable to 8

         CLR CS             ;activate the ADC
 
         SETB CLK           ;0 to 1 transition of CLK
         CLR CLK            ;1 to 0 transition of CLK
         SETB CLK           ;0 to 1 transition of CLK
         CLR CLK            ;1 to 0 transition of CLK,
                            ;this to insert two CLK periods
   
NO_DATA: SETB CLK           ;0 to 1 transition of CLK
         MOV C,ADCDO        ;read the data
         CLR CLK            ;1 to 0 transition of CLK
         RLC A              ;fabricate the ADC data byte
         DJNZ TEMP,NO_DATA  ;read all 8 bits

         SETB CS            ;deactivate the ADC

         RET                ;return from subroutine


Kai

List of 22 messages in thread
TopicAuthorDate
Problem Humidity Project            01/01/70 00:00      
   Which humidity sensor?            01/01/70 00:00      
      Problem Humidity Project            01/01/70 00:00      
         Datasheet?            01/01/70 00:00      
            Problem Humidity Project            01/01/70 00:00      
         2-byte character            01/01/70 00:00      
   Finding %RH            01/01/70 00:00      
   Temperature compensation needed?            01/01/70 00:00      
      Surely            01/01/70 00:00      
         Why bother?            01/01/70 00:00      
            Why bother?            01/01/70 00:00      
               Problem Humidity Project            01/01/70 00:00      
   Problem Humidity Project            01/01/70 00:00      
      Comment your code!            01/01/70 00:00      
         Problem With ADC Code            01/01/70 00:00      
            Where are the comments??            01/01/70 00:00      
            Problem With ADC Code            01/01/70 00:00      
            Try this            01/01/70 00:00      
               Mixing 3V and 5V chips            01/01/70 00:00      
                  3.3v sensor, 5v chip            01/01/70 00:00      
                     The problem is...            01/01/70 00:00      
                        but then            01/01/70 00:00      

Back to Subject List