Open GoogleCodeExporter opened 9 years ago
[deleted comment]
This solves the problem:
void collect_view_arch_read_sensors(struct collect_view_data_msg *msg)
{
SENSORS_ACTIVATE(ds1000);
printf("");
msg->sensors[CO_SENSOR] = ds1000.value(SENSOR_CO);
SENSORS_DEACTIVATE(ds1000);
}
But this doesn't (same result for clock_delay or clock_wait)
void collect_view_arch_read_sensors(struct collect_view_data_msg *msg)
{
SENSORS_ACTIVATE(ds1000);
static int i=1000;
while(i>0)i--;
msg->sensors[CO_SENSOR] = ds1000.value(SENSOR_CO);
SENSORS_DEACTIVATE(ds1000);
}
Original comment by eldial@gmail.com
on 8 Aug 2012 at 4:22
Clarification about collect-view-z21.c:
It doesn't have the same problem.
~/contiki/platform/z21/dev/tmp102.c
doesn't implement a function to stop tmp102
Original comment by eldial@gmail.com
on 10 Aug 2012 at 1:20
This solves the the problem, and it is the right way:
void collect_view_arch_read_sensors(struct collect_view_data_msg *msg)
{
SENSORS_ACTIVATE(ds1000);
while (!ds1000.status(SENSORS_READY));
msg->sensors[CO_SENSOR] = ds1000.value(SENSOR_CO);
SENSORS_DEACTIVATE(ds1000);
}
Details:
1. From sky-sensors.c:
int
sky_sensors_status(uint16_t input, int type)
{
if(type == SENSORS_ACTIVE) {
return (adc_on & input) == input;
}
if(type == SENSORS_READY) {
ready |= ADC12IFG & adc_on & input;
return (ready & adc_on & input) == input;
}
return 0;
}
2. From MSP430 user's guide (ADC12 Chapter)
"When conversion results are written to a selected ADC12MEMx, the corresponding
flag
in the ADC12IFGx register is set."
Conclusion:
One must wait for the ADC12 to place first conversions on selected ADC12MEM
registers. Also, contiki file "collect-view-sky.c" could be patched (for
safety) even though problem won't happen there (SENSORS_ACTIVATE(ds1000)
enables 3 conversions at one call, not the case in collect-view-sky.c).
Original comment by eldial@gmail.com
on 13 Aug 2012 at 1:04
Original issue reported on code.google.com by
eldial@gmail.com
on 8 Aug 2012 at 11:58