Jump to content

rnightbane

Members
  • Content Count

    9
  • Joined

  • Last visited

  1. rnightbane

    TivaC sample ADC code problem

    I see, but what if I want to change the ADC speed, how do I change it if analogRead() already has its ADC set up as it is? And how many bits does the ADC transfer to UART?
  2. rnightbane

    TivaC sample ADC code problem

    #include "Energia.h" #include "driverlib/sysctl.h" #include "driverlib/adc.h" #define A3 PE_0 void setup() { Serial.begin(512000); SysCtlADCSpeedSet(SYSCTL_ADCSPEED_1MSPS); SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_0); ADCHardwareOversampleConfigure(ADC0_BASE, 64); ADCSequenceDisable(ADC0_BASE, 3); ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_PROCESSOR, 0); ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_CH0 | ADC_CTL_END); ADCSequenceEnable(ADC0_BASE, 3); } void loop() { int f; ADCProcessorTrigger(ADC0_BASE, 3); f = analogRead(A3); Serial.write(f); } thanks for answering my question... i modified a bit of his code, and placed analogRead() in place of AnalogSequenceGet(), so is my pin for analogRead() right? Since I assumed that PE_0 is the ADC pin used...
  3. rnightbane

    TivaC sample ADC code problem

    Hi! How do you access the result of the ADC? Given that you put an input analog signal on the GPIO pin...
  4. rnightbane

    ADC and USB Data sending to MatLab

    is that some standalone program?
  5. rnightbane

    ADC and USB Data sending to MatLab

    Okay, so I found out from my previous post that the output value from the ADC can be accessed through pui32ADC0Value...now, im trying to send that data via USB device mode in Tiva, however, my concerns are will my code work? And if it works, how do I access that data via MatLab. Thanks Once again, credits to the maker of the ADC code. #include <stdbool.h> #include <stdint.h> #include "inc/hw_memmap.h" #include "driverlib/adc.h" #include "driverlib/gpio.h" #include "driverlib/sysctl.h" #include "driverlib/adc.h" #include "inc/hw_types.h" #include "driverlib/debug.h" #include "driverlib/usb.h" #include "usblib/usblib.h" #include "usblib/usblibpriv.h" #include "usblib/device/usbdevice.h" #include "usblib/device/usbdevicepriv.h" main(void) { uint32_t pui32ADC0Value[1]; SysCtlClockSet(SYSCTL_SYSDIV_10 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN| SYSCTL_XTAL_16MHZ); //Set clock at 40 Mhz , Sometimes //ADC may not work at 80Mhz SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); ADCReferenceSet(ADC0_BASE, ADC_REF_INT); //Set reference to the internal reference // You can set it to 1V or 3 V GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_5); //Configure GPIO as ADC ADCSequenceDisable(ADC0_BASE, 3); //It is always a good practice to disable ADC prior //to usage ,else the ADC may not be accurate // due to previous initializations ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_PROCESSOR, 0); //Use the 3rd Sample sequencer ADCSequenceStepConfigure(ADC0_BASE, 3, 0,ADC_CTL_CH8 | ADC_CTL_IE | ADC_CTL_END); //Configure ADC to read from channel 8 ,trigger the interrupt to end data capture // ADCSequenceEnable(ADC0_BASE, 3); //Enable the ADC ADCIntClear(ADC0_BASE, 3); //Clear interrupt to proceed to data capture uint8_t* Data = "pui32ADC0Value"; // // Configure Endpoint 1. // USBDevEndpointConfigSet(USB0_BASE, USB_EP_1, 64, //DISABLE_NAK_LIMIT, USB_EP_MODE_BULK | USB_EP_DEV_IN); // // Configure FIFO as a device IN endpoint FIFO starting at address 64 // and is 64 bytes in size. // USBFIFOConfigSet(USB0_BASE, USB_EP_1, 64, USB_FIFO_SZ_64, USB_EP_DEV_IN); while (1) { ADCProcessorTrigger(ADC0_BASE, 3); //Ask processor to trigger ADC while (!ADCIntStatus(ADC0_BASE, 3, false)) { //Do nothing until interrupt is triggered } ADCIntClear(ADC0_BASE, 3); //Clear Interrupt to proceed to next data capture ADCSequenceDataGet(ADC0_BASE, 3, pui32ADC0Value); //pui32ADC0Value is the value read SysCtlDelay(SysCtlClockGet() / 12); // // Put the data in the FIFO. // USBEndpointDataPut(USB0_BASE, USB_EP_1, Data, 64); // // Start the transmission of data. // USBEndpointDataSend(USB0_BASE, USB_EP_1, USB_TRANS_IN); //USBEndpointDataGet(USB0_BASE, USB_EP_1, Data, 32); } //Suitable delay }
  6. rnightbane

    ADC Output

    Thanks for the suggestions. Is it possible if I send pui32ADC0Value via UART?
  7. rnightbane

    ADC Output

    Yes. How to access the result AND how to display it. Actually, I had an idea of using MatLab to display the output by using the FFT function on MatLab for the result of the ADC, however, I have no idea how to.
  8. rnightbane

    ADC Output

    Hi, I recently found a ADC code in the forums. I plan to input it with a signal, but I dont know where to test the output. Here's the code, credits to the maker. #include <stdbool.h> #include <stdint.h> #include "inc/hw_memmap.h" #include "driverlib/adc.h" #include "driverlib/gpio.h" #include "driverlib/sysctl.h" #include "driverlib/adc.h" #include "inc/hw_types.h" #include "driverlib/debug.h" main(void) { uint32_t pui32ADC0Value[1]; SysCtlClockSet(SYSCTL_SYSDIV_10 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN| SYSCTL_XTAL_16MHZ); //Set clock at 40 Mhz , Sometimes //ADC may not work at 80Mhz SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); ADCReferenceSet(ADC0_BASE, ADC_REF_INT); //Set reference to the internal reference // You can set it to 1V or 3 V GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_5); //Configure GPIO as ADC ADCSequenceDisable(ADC0_BASE, 3); //It is always a good practice to disable ADC prior //to usage ,else the ADC may not be accurate // due to previous initializations ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_PROCESSOR, 0); //Use the 3rd Sample sequencer ADCSequenceStepConfigure(ADC0_BASE, 3, 0,ADC_CTL_CH8 | ADC_CTL_IE | ADC_CTL_END); //Configure ADC to read from channel 8 ,trigger the interrupt to end data capture // ADCSequenceEnable(ADC0_BASE, 3); //Enable the ADC ADCIntClear(ADC0_BASE, 3); //Clear interrupt to proceed to data capture while (1) { ADCProcessorTrigger(ADC0_BASE, 3); //Ask processor to trigger ADC while (!ADCIntStatus(ADC0_BASE, 3, false)) { //Do nothing until interrupt is triggered } ADCIntClear(ADC0_BASE, 3); //Clear Interrupt to proceed to next data capture ADCSequenceDataGet(ADC0_BASE, 3, pui32ADC0Value); //pui32ADC0Value is the value read SysCtlDelay(SysCtlClockGet() / 12); } //Suitable delay }
  9. rnightbane

    Analog to Digital Conversion on Tiva C Series MCU

    how do i test the output of this adc using matlab? does this need a USB initialization code?
×