Author: sebastien.lelong
Date: Mon Jun 8 22:34:32 2009
New Revision: 1037
Modified:
trunk/include/peripheral/adc/adc.jal
trunk/sample/16f88_adc_lowres.jal
trunk/test/unittest/16f88_adc.jalt
Log:
fix turn on ADC module, use print in sample
Modified: trunk/include/peripheral/adc/adc.jal
==============================================================================
--- trunk/include/peripheral/adc/adc.jal (original)
+++ trunk/include/peripheral/adc/adc.jal Mon Jun 8 22:34:32 2009
@@ -59,6 +59,7 @@
procedure _adc_read_low_res(byte in adc_chan, byte out adc_byte) is
ADCON0_CHS = adc_chan
+ ADCON0_ADON = true -- turn on ADC module
delay_10us(adc_conversion_delay) -- wait acquisition time
ADCON0_GO = true -- start conversion
while ADCON0_GO loop end loop -- wait till conversion finished
@@ -77,10 +78,11 @@
-- tad_value comes from adc_clock
-- we won't be that accurate here (mostly because there's no
delay_usec(byte in x) procedure)
if tad_value >= (ADC_MAX_TAD + ADC_MIN_TAD) / 2 then
- _usec_delay(2 * ADC_MAX_TAD)
+ _usec_delay(2 * ADC_MAX_TAD)
else
- _usec_delay(2 * ADC_MIN_TAD)
+ _usec_delay(2 * ADC_MIN_TAD)
end if
+ ADCON0_ADON = false -- turn off ADC module
end procedure
Modified: trunk/sample/16f88_adc_lowres.jal
==============================================================================
--- trunk/sample/16f88_adc_lowres.jal (original)
+++ trunk/sample/16f88_adc_lowres.jal Mon Jun 8 22:34:32 2009
@@ -48,6 +48,7 @@
-- no watchdog, please
pragma target WDT disabled
+include print
include delay
-- ok, now setup serial
const usart_hw_serial = true -- true = RS232, false = SPI
@@ -81,7 +82,8 @@
-- get ADC result, on channel 0
measure = adc_read_low_res(0)
-- send it back through serial
- serial_hw_write(measure)
+ print_byte_dec(serial_hw_data,measure)
+ print_crlf(serial_hw_data)
-- and sleep a litte...
delay_1ms(200)
end loop
Modified: trunk/test/unittest/16f88_adc.jalt
==============================================================================
--- trunk/test/unittest/16f88_adc.jalt (original)
+++ trunk/test/unittest/16f88_adc.jalt Mon Jun 8 22:34:32 2009
@@ -93,7 +93,9 @@
test_byte(adc_conversion_delay) ;@assertEquals 21 test_compute_delay
set_analog_pin(0)
-
+asm nop
+var byte adcon1_vcfg = ADCON1 & 0b_0011_0000
+test_byte(adcon1_vcfg) ;@assertEquals 2 test_vcfg
-- XYY
-- adcs =? 0b_010
asm nop
@@ -112,8 +114,8 @@
const word ADC_RSOURCE = 10_000
include adc
adc_init()
+test_byte(adc_conversion_delay) ;@assertEquals 21 test_compute_delay
set_analog_pin(0)
-
-- XYY
-- adcs =? 0b_010
asm nop
@@ -133,7 +135,6 @@
include adc
adc_init()
set_analog_pin(0)
-
-- XYY
-- adcs =? 0b_101
asm nop
@@ -153,7 +154,6 @@
include adc
adc_init()
set_analog_pin(0)
-
-- XYY
-- adcs =? 0b_101
asm nop
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---