Hello everyone,

I am working with the MSP430F2617 microcontroller and CC2420 radio. I'm
using Zolertia driver.

I have written an application that sends temperature readings every 2
seconds microcontroller to a base station (BaseStation Application). The
readings are consistent and depending if you use the power of two batteries
or USB power values ​​are different but them are apparently valid.

The configuration selected in the case of temperature is:

 msp430adc12_channel_config_t adcconfig = {
    inch: TEMPERATURE_DIODE_CHANNEL,
    SREF: REFERENCE_AVcc_AVss,
    ref2_5v: REFVOLT_LEVEL_1_5,
    adc12ssel: SHT_SOURCE_ACLK,
    adc12div: SHT_CLOCK_DIV_1,
    sht: SAMPLE_HOLD_4_CYCLES,
    sampcon_ssel: SAMPCON_SOURCE_SMCLK,
    sampcon_id: SAMPCON_CLOCK_DIV_1
  };

Now, I want to read the internal voltage of the microcontroller, but always
gives OFFF reading if I use both batteries (2.6 V) or with USB power (3.3V)
and I do not know the error Could someone help me?

The code used in the case of voltage is:


TestAdcC.nc

#include "Timer.h"
#include "TestAdc.h"

module TestAdcC
{
  uses interface Boot;
  uses interface Leds;

  uses interface Timer<TMilli> as Timer0;

  uses interface Msp430Adc12Overflow as overflow;
  uses interface Msp430Adc12SingleChannel as adc;
  uses interface Resource;

  uses interface SplitControl as Control;
  uses interface Packet;
  uses interface AMSend;
}

implementation
{
#define BUF_SIZE 100
uint16_t buf[BUF_SIZE];
message_t packet;
uint16_t counter = 0;
uint16_t Data;

void configureSingle();

msp430adc12_channel_config_t adcconfig = {
    inch: SUPPLY_VOLTAGE_HALF_CHANNEL,
    sref: REFERENCE_VREFplus_AVss,
    ref2_5v: REFVOLT_LEVEL_1_5,
    adc12ssel: SHT_SOURCE_ACLK,
    adc12div: SHT_CLOCK_DIV_1,
    sht: SAMPLE_HOLD_4_CYCLES,
    sampcon_ssel: SAMPCON_SOURCE_SMCLK,
    sampcon_id: SAMPCON_CLOCK_DIV_1
  };

event void Boot.booted()
  {
call Leds.led0Off();
call Leds.led1Off();
call Leds.led2Off();
call Control.start();
call Resource.request();
 }

async event void overflow.conversionTimeOverflow(){
}

async event void overflow.memOverflow(){
}

async event uint16_t *adc.multipleDataReady(uint16_t *buffer, uint16_t
numSamples){
            return buffer;
}

task void send(){
    test_serial_msg_t* rcm = (test_serial_msg_t*)call
Packet.getPayload(&packet, sizeof(test_serial_msg_t));
    call Leds.led0Toggle();
    rcm->counter = Data;
    if(  call AMSend.send(AM_BROADCAST_ADDR, &packet,
sizeof(test_serial_msg_t)) == SUCCESS){
        call Leds.led1Toggle();
     }
}

async event error_t adc.singleDataReady(uint16_t data){
    Data = data;
    post send();
        return SUCCESS;
  }

event void Resource.granted(){
    configureSingle();
        call Timer0.startPeriodic(2048);
  }

void configureSingle(){
    error_t e;
    e = call adc.configureSingle(&adcconfig);
     }

event void Timer0.fired()
  {
    call adc.getData();
  }

event void AMSend.sendDone(message_t* bufPtr, error_t error) {
    call Leds.led2Toggle();
}

event void Control.startDone(error_t err) {
  if (err == SUCCESS){
        } else {
    call Control.start();
      }
}

event void Control.stopDone(error_t err) {
    }

}


TestAdcAppC.nc

#include "TestAdc.h"
configuration TestAdcAppC {
}
implementation
{
  components MainC,
             TestAdcC,
             LedsC;
 components ActiveMessageC as AM;
 components new TimerMilliC() as Timer0;
 components new Msp430Adc12ClientAutoDMAC() as Lectura;

 TestAdcC.overflow -> Lectura;
  TestAdcC.adc -> Lectura;
  TestAdcC.Resource -> Lectura;

  TestAdcC -> MainC.Boot;
  TestAdcC.Leds -> LedsC;
  TestAdcC.Timer0 -> Timer0;
  TestAdcC.Control -> AM;
  TestAdcC.AMSend -> AM.AMSend[AM_TEST_SERIAL_MSG];
  TestAdcC.Packet -> AM;

}


TestAdc.h

#ifndef TEST_SERIAL_H
#define TEST_SERIAL_H

typedef nx_struct test_serial_msg {
  nx_uint16_t counter;
} test_serial_msg_t;

enum {
  AM_TEST_SERIAL_MSG = 0x89,
};

#endif


Makefile

#ifndef TEST_SERIAL_H
#define TEST_SERIAL_H

typedef nx_struct test_serial_msg {
  nx_uint16_t counter;
} test_serial_msg_t;

enum {
  AM_TEST_SERIAL_MSG = 0x89,
};

#endif

A greeting and thank you very much!.
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to