This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

ADC10 one channel repeated samples DTC



Hello guys,

I'm working in a project with the ez430-cc2480 module, I know that it is obsolete but is what I have. The goal of this project is to measure an analog signal continously and as fast as possible in order to draw in the computer the signal wave with the data.

I'm using ZASA code with the changes needed to  do this, but I'm having some problems.

This part of the code configure the ADC10, including the DTC (128 samples, also tried small number but didn't work):

void halReadBusV(void)
{
ADC10CTL0 &= ~ENC;
ADC10CTL0 = SREF_2 + ADC10ON + ADC10SHT_2 + MSC + REF2_5V + REFON + ADC10IE;
ADC10CTL1 = SHS_0 + ADC10SSEL_0 + INCH_2 + ADC10DIV_0 + CONSEQ_2;


ADC10DTC1=0x80;
ADC10CTL0 |= ENC + ADC10SC;
}


this part is the ADC interrupt:

INTERRUPT_ADC10()
{
  halAdcVal = ADC10SA;  //Direction of the first conversion
  halEventFlags |= HAL_EVT_ADC;  // Signal that the ADC sample is ready.
  ADC10CTL0 = 0;                 // Disable the ADC
  ADC10CTL0 = 0;                 // Turn off reference (must be done AFTER clearing ENC).
 
  __low_power_mode_off_on_exit();
}


and here I move each conversion to the send buffer:


static void appSrceData(void)
{
  uint16 tmp;
  int i;

 for (i=0;i<256;i++)   //256 because each conversion is in 2 bytes
 {
  tmp=ADC10SA*25/1023;
  srceReport[i]=(uint16)tmp;

i++;
 }
  halReadBusV();
 

#if APP_DATA_CNF
    if (APP_SRCE)
    {
      // Increment the message handle so that the next message is unique.
      zb_SendDataRequest (ZB_BINDING_ADDR, SRCE_REPORT_ID, appMsgHandle++,
                          AF_ACK_REQUEST, AF_DEFAULT_RADIUS, SRCE_REPORT_SZ, srceReport);

      /* An RFD needs a timer to wake from sleep and poll the ZACCEL for the ZACCEL_SEND_DATA_CNF.
       * An FFD will always be awake and ready to poll for it.
       */
      if (appFlags & appLowPwrF)
      {
        halTimerSet(HAL_IDX_TIMER_APP, APP_REPORT_RETRY, HAL_TIMER_AUTO);
      }

      appMsgRtry = APP_RETRY_CNT;
      appFlags |= appSendingF;
    }
#else
    zb_SendDataRequest (ZB_BINDING_ADDR, SRCE_REPORT_ID, appMsgHandle++,
                        0, AF_DEFAULT_RADIUS, SRCE_REPORT_SZ, srceReport);
    appLedBlink(APP_DATA_LED);
#endif

 
}


- ¿Am I moving the data correctly?


- Z-Tool only shows the data when I send 64 conversions, but if I try to send more than 100 more or less, the data doesn't appear in Z-Tool. Why?


THANKS !!!!!!!

  • Hmmmh, apparently nobody knows/uses Zasa or of those who do, nobody has an idea.

    Well, some ideas:

    1) appSrceData looks strange. YOu comment '256 becuause each sampel is two bytes) but you are already handling INTs which are 2 bytes. So why this comment? Are there 256 dtatapoints (%12 bytes in total) or what?

    2) how is srceReport defined? If it is an array for 128 values, putting 256 values in it will surely cause havoc on your othe rglobal variables and parhaps even the stack. Why do you cast tmp to int16 while it is an int16 already?

    3) AC10SA*25/1023 looks very strange. ADC10SA is the start address for the data transfer, and not the address and even less the value of an individual conversion. So this formula makes no sense. Maybe you meant something like (*((int16 *)ADC10SA+i))*25/1023 ?

    4) what is the MSP on this EZ? Does it have enough ram to hold the samples, the stack and your local variables?

**Attention** This is a public forum