Fixed. The correct value is REFERENCE_AVcc_VREFnegterm.
However I do have some library linking problem when compiling an app wired
directly to Msp430Adc12ClientAutoDMA_RVGC. Here is the error message:
xubun...@xubuntos-tinyos:/opt/tinyos-2.1.0/apps/SBT80Apps/RadarReader$ make
telosb
mkdir -p build/telosb
compiling SBT80TestC to a telosb binary
ncc -o build/telosb/main.exe -Os -O -mdisable-hwmul -Wall -Wshadow -Wnesc-all
-target=telosb -fnesc-cfile=build/telosb/app.c -board=
-DDEFINED_TOS_AM_GROUP=0x22 -I/opt/tinyos-2.1.0/tos/lib/printf
-DTOSH_DATA_LENGTH=114 -DIDENT_APPNAME=\"SBT80TestC\"
-DIDENT_USERNAME=\"xubuntos\" -DIDENT_HOSTNAME=\"xubuntos-tinyos\"
-DIDENT_USERHASH=0x00f95284L -DIDENT_TIMESTAMP=0x49b6c376L
-DIDENT_UIDHASH=0x317dfa32L SBT80TestC.nc -lm
/usr/bin/../lib/gcc-lib/msp430/3.2.3/msp2/libgcc.a(_reset_vector__.o): In
function `_reset_vector__':
/home/xubuntos/tinyos-toolchain-packages/sources/msp430-build-tinyos-2.1/build/gcc-3.2.3/gcc/config/msp430/libgcc.S:(.init+0x38):
undefined reference to `main'
make: *** [exe0] Error 1
xubun...@xubuntos-tinyos:/opt/tinyos-2.1.0/apps/SBT80Apps/RadarReader$
Does anyone know what this cryptic message means and/or how to solve it?
Here is my applications configuration file:
#include <Timer.h>
#include "printf.h"
configuration SBT80TestAppC {
}
implementation {
components MainC;
components LedsC;
components HplMsp430GeneralIOC;
components RadarC as App;
components new TimerMilliC() as Timer0;
//Each one corresponds to an ADC ch
components new Msp430Adc12ClientAutoDMA_RVGC() as Sensor1;
//Radio components
components ActiveMessageC;
components new AMSenderC(AM_SBT80MSG);
components new AMReceiverC(AM_SBT80MSG);
App.Boot -> MainC;
App.Leds -> LedsC;
App.Timer0 -> Timer0;
App.Resource -> Sensor1.Resource;
App.ReadSensor -> Sensor1.Msp430Adc12SingleChannel;
//Switch between Accelerometer and Magnetometer
App.SBcontrol -> HplMsp430GeneralIOC.Port23;
App.SBswitch -> HplMsp430GeneralIOC.Port26;
// Radio wiring
App.RadioControl -> ActiveMessageC;
App.AMSend -> AMSenderC;
App.Receive -> AMReceiverC;
}
Here is the implementation file
#include <Timer.h>
#include "SBT80.h"
module SBT80TestC {
uses {
interface Boot;
interface Leds;
interface Timer<TMilli> as Timer0;
interface Resource;
interface Msp430Adc12SingleChannel as ReadSensor;
interface HplMsp430GeneralIO as SBcontrol;
interface HplMsp430GeneralIO as SBswitch;
interface SplitControl as RadioControl;
interface AMSend;
interface Receive;
}
}
implementation {
message_t sendbuf;
SBT80Msg_t local;
bool sendbusy = FALSE;
uint16_t buffer[SAMPLE_BUFFER_SIZE];
uint16_t offset = 0;
uint16_t i;
uint16_t sampling_frame = 0;
uint16_t sequence = 0;
bool sentFullBuffer = FALSE;
const msp430adc12_channel_config_t config = {
INPUT_CHANNEL_A0, REFERENCE_AVcc_VREFnegterm, REFVOLT_LEVEL_NONE,
SHT_SOURCE_SMCLK, SHT_CLOCK_DIV_1, SAMPLE_HOLD_4_CYCLES,
SAMPCON_SOURCE_SMCLK, SAMPCON_CLOCK_DIV_1
};
void report_problem(){ call Leds.led0Toggle();}
void report_sent(){ call Leds.led1Toggle();}
void report_received(){ call Leds.led2Toggle();}
event void Boot.booted() {
if(call RadioControl.start() != SUCCESS){
report_problem();
}
}
event void RadioControl.startDone(error_t error){
local.id = TOS_NODE_ID;
}
event void Resource.granted()
{
error_t result;
result = call ReadSensor.configureMultiple(&config, buffer,
SAMPLE_BUFFER_SIZE, SAMPLE_PERIOD);
if (result == SUCCESS)
call ReadSensor.getData();
}
event void RadioControl.stopDone(error_t error){
}
event void AMSend.sendDone(message_t* msg, error_t error){
if(error == SUCCESS){
report_sent();
sendbusy = FALSE;
//increment info
sequence++;
if(sentFullBuffer){
//reset values
offset = 0;
sentFullBuffer = FALSE;
}else{
call Timer0.startOneShot(10);
}
}else{
report_problem();
}
}
event message_t* Receive.receive(message_t* msg, void* payload, uint8_t
len){
SentryMsg_t *smsg = payload;
report_received();
call Resource.request();
return msg;
}
async event uint16_t* ReadSensor.multipleDataReady(uint16_t *buf,
uint16_t length)
{
call Timer0.startOneShot(5);
}
async event error_t ReadSensor.singleDataReady(uint16_t data)
{
}
event void Timer0.fired(){
// set other info for this packet
local.sequence = sequence;
local.bufferPos = offset;
// copy I_buffer into local
for(i = 0; i < PACKET_BUFFER_SIZE; i++){
local.readings[i] = buffer[offset++];
if(offset == SAMPLE_BUFFER_SIZE){
sentFullBuffer = TRUE;
break;
}
}
//send packet
if(!sendbusy){
memcpy(call AMSend.getPayload(&sendbuf,0),
&local,sizeof local);
if(call AMSend.send(1,
&sendbuf,sizeof local) == SUCCESS)
sendbusy = TRUE;
else
report_problem();
}else{
report_problem();
}
}
}
-Ernest McCracken
________________________________________
From: Ernest Andrew McCracken (emccrckn)
Sent: Tuesday, June 23, 2009 1:01 PM
To: [email protected]
Cc: Lan Wang (lanwang)
Subject: Questions about ADC
Hi I have a few questions concerning the ADC software components. The platform
we use is the telosb. Maybe someone knows or can point me in the right
direction.
First Question:
According to TEP 101 the MSP430 has several selectable reference voltage
combinations. These can be set using AdcConfigure interface. I want to be
able to use ‘AVcc and (Vref-)’ but I do not know the value that corresponds to
this for the parameter sref in :
typedef struct
{
unsigned int inch: 4; // input channel
unsigned int sref: 3; // reference voltage
unsigned int ref2_5v: 1; // reference voltage level
unsigned int adc12ssel: 2; // clock source sample-hold-time
unsigned int adc12div: 3; // clock divider sample-hold-time
unsigned int sht: 4; // sample-hold-time
unsigned int sampcon_ssel: 2; // clock source sampcon signal
unsigned int sampcon_id: 2; // clock divider sampcon signal
} msp430adc12_channel_config_t;
Does anyone know what value corresponds to Avcc and Vref- ?
Second Question:
Currently we are using the AdcReadStreamClient to read a single channel at high
sampling frequencies. However I have found that I cannot sample faster than
1.8 kHz. According to the MSP430 User’s Guide the ADC is capable of 200+ ksps.
I have found that the AdcReadStreamClient uses component
Msp430Adc12ClientAutoRVGC. I have also found the component
Msp430Adc12ClientAutoDMA_RVGC which copies samples using DMA. This later
component should enable me to sample faster correct? If so does anyone know of
any implementations of this component in an application that I can look at. If
not does anyone know of any other techniques that could enable faster sampling
from the ADC?
Ernest McCracken
Research Assistant
Networking Research Laboratory
Computer Science Department
University of Memphis
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help