Jump to content

nrdmtt

Members
  • Content Count

    3
  • Joined

  • Last visited

  1. Hi, Did you sort out this problem? I think I am facing the same problem. I have developed a device based on the CC3200mod chip, but in no way I am able to read the ADC input. Any help would really appreciated. This is really frustrating. Thank you.
  2. Hi, I have tried as suggested, but the problem persist.
  3. Hi, I am trying to get the ADC sample timestamp on Energia, but I can not figure it out how it works. From the TI API I know that the ADC data saved on the register is made by two parts. bits [13:0] : ADC sample bits [31:14]: time stamp per ADC sample So I took the Energia library. From <driverlib/adc.h> and I found a method that returns only the time stamp. //***************************************************************************** // //! Gets the current value of ADC internal timer //! //! \param ulBase is the base address of the ADC //! //! This function the current value of 17-bit ADC internal timer //! //! \returns Return the current value of ADC internal timer. // //***************************************************************************** unsigned long ADCTimerValueGet(unsigned long ulBase) { return(HWREG(ulBase + ADC_O_adc_timer_current_count)); } So I have modified the wiring_analog.c library: uint16_t analogRead(uint8_t pin) { uint16_t channel, val; uint16_t pinNum = digitalPinToPinNum(pin); switch(pinNum) { case PIN_57: {channel = ADC_CH_0;}break; case PIN_58: {channel = ADC_CH_1;}break; case PIN_59: {channel = ADC_CH_2;}break; case PIN_60: {channel = ADC_CH_3;}break; default: return 0; } while(ADCFIFOLvlGet(ADC_BASE, channel)) { // flush the channel's FIFO if not empty ADCFIFORead(ADC_BASE, channel); } PinTypeADC(pinNum,0xFF); ADCChannelEnable(ADC_BASE, channel); ADCTimerConfig(ADC_BASE,2^17); ADCTimerEnable(ADC_BASE); ADCEnable(ADC_BASE); while(!ADCFIFOLvlGet(ADC_BASE, channel)); val = ADCFIFORead(ADC_BASE, channel) & 0x3FFF; // ***** TIME STAMP FIELD **** timestamp = ADCTimerValueGet(ADC_BASE); // ***** TIME STAMP FIELD **** ADCDisable(ADC_BASE); ADCChannelDisable(ADC_BASE, channel); ADCTimerDisable(ADC_BASE); val = val >> 2; return val; } // Return the ADC sample time stamp unsigned long ADCGetTime() { return timestamp; } And this is my test sketch #include <wiring_analog.c> int sensorPin = 2; // select the input pin for the potentiometer uint16_t long sensorValue[5] = {0}; // variable to store the value coming from the sensor unsigned long time[5] = {0}; unsigned long m = 0; unsigned int seconds = 0; unsigned int minutes = 0; unsigned int hours = 0; void setup() { Serial.begin(115200); } void loop() { // read the value from the sensor: for (int i = 0; i< 5; i++) { sensorValue [i] = analogRead(sensorPin); time[i] = ADCGetTime(); delay(1); } for(int i = 0; i < 5; i++) { minutes = ( time[i] / 1000 / 60); seconds = ( time[i] / 1000) % 60; m = ( time[i] % 100); Serial.println("ADC VALUE: "); Serial.print(sensorValue[i]); Serial.print(" --- TIME STAMP: "); Serial.print(minutes); Serial.print(":"); Serial.print(seconds); Serial.print(":"); Serial.println(m); Serial.print("\n"); } delay(5000); } The problem is that the value of the variable time do not change. It's always the same. What is wrong with my test sketch? How can I access to the time stamp of my samples? Thank you in advance.
×
×
  • Create New...