Author: sebastien.lelong
Date: Mon Jun 29 09:11:03 2009
New Revision: 1064

Modified:
    trunk/include/peripheral/adc/adc.jal

Log:
issue-77: fix 10-bits -> 8-bits result conversion

Modified: trunk/include/peripheral/adc/adc.jal
==============================================================================
--- trunk/include/peripheral/adc/adc.jal        (original)
+++ trunk/include/peripheral/adc/adc.jal        Mon Jun 29 09:11:03 2009
@@ -130,21 +130,16 @@
  -- It doesn't matter if ADC is set to low or high resolution
  function adc_read_low_res(byte in adc_chan) return byte is
     var byte adc_value
-   var byte adc_hbyte
     if ! ADC_HIGH_RESOLUTION then
        _adc_read_low_res(adc_chan,adc_value)
     else
-      _adc_read_low_res(adc_chan,adc_hbyte)
-      adc_value = ADRESL
-      -- shift the 2 highest order bits form high byte to low byte
-         adc_hbyte = adc_hbyte >> 1
-         adc_value = adc_value >> 1
-         adc_hbyte = adc_hbyte >> 1
-         adc_value = adc_value >> 1
-      ;;asm  rrf   adc_hbyte,f
-      ;;asm  rrf   adc_value,f
-      ;;asm  rrf   adc_hbyte,f
-      ;;asm  rrf   adc_value,f
+         var word shift_alias
+         var byte ax[2] at shift_alias
+      _adc_read_low_res(adc_chan,ax[1])
+      ax[0] = ADRESL
+      -- shift 2 bits away to remove the 2 LSb
+         shift_alias = shift_alias >> 2
+         adc_value = ax[0]
     end if
     return adc_value
  end function

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jallib" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/jallib?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to