Jump to content

RAKSH

Members
  • Content Count

    19
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by RAKSH


  1. For the sake of thanking this community for solving my issue ,I would like to write a post on how I overcame this issue thanks to community member Stepman .

    I use the TIva C Series Launchpad .

    For a program employing UART if you are getting errors like  
     

    Description Resource Path Location Type
    unresolved symbol UARTprintf, first referenced in ./main.obj 
     

    Description Resource Path Location Type
    unresolved symbol UARTStdioConfig, first referenced in ./main.obj 

    Then you have not copied or linked your uartstdio.c file from utils/uartstdio.c

    If you are getting errors like
     

    Description Resource Path Location Type
    #20 identifier "GPIO_PA0_U0RX" is undefined main.c /SPI line 113 C/C++ Problem
     

    Description Resource Path Location Type
    #20 identifier "GPIO_PA1_U0TX" is undefined main.c /SPI line 114 C/C++ Problem

    Then you have to do the following steps :-

    1.Right Click on your project and go to properties->arm compiler->advanced options->predefined symbols
    2.Their , in the Pre-Define name area add

        a)PART_TM4C123GH6PM or whichever MCU part name you are using 
        b)PART_IS_BLIZZARD_RB1 for the Tiva C series and PART_IS_BLIZZARD_RA1 for previous versions .


    The above should also be of help when you get errors related to other Pin definitions such as for SPI and PWM pin defs.


    Make sure that if you have included  DEBUG in pre-define names then you include  debug statements as follows
    in main.c

    //*****************************************************************************
    //
    // The error routine that is called if the driver library encounters an error.
    //
    //*****************************************************************************
    #ifdef DEBUG
    void
    __error__(char *pcFilename, uint32_t ui32Line)
    {
        UARTprintf("Error at line %d of %s\n", ui32Line, pcFilename);
        while(1)
        {
        }
    }
    #endif
    

    Prior to the above make sure that you have added driverlib.lib in properties->arm linker->include library
    Navigate to driverlib->CCS->Debug->driverlib.lib

    Make sure that you also add this file to your project .


    And if you are on a noob level don't forget to include TivaWare directory in your include options . 


  2. Here's  code performing ADC on Pin E5 on the Tiva C Series meant for struggling beginners like myself

    #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
    }
    
    

    It is important to refer to datasheet before selecting the GPIO for the ADC and the channel through which it is done .
     


  3. Thanks but I resolved my issue .
    The problem was , I was using a wrong channel to read values .
    And also ,that it is necessary to clear all Interrupts on the ADC before proceeding .

    Thanks a lot guys !


  4. I'm trying to read analog values from a photoresistor(off of a voltage divider) connected to pin PC5 .
    I use the following code 

     
    #include <stdint.h>
    #include <stdbool.h>
    #include "inc/hw_memmap.h"
    #include "inc/hw_types.h"
    #include "driverlib/debug.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/adc.h"
    #include "driverlib/gpio.h"
    
    #ifdef DEBUG
    void__error__(char *pcFilename, uint32_t ui32Line)
    {
    }
    #endif
    
    int main(void)
    {
    uint32_t ui32ADC0Value[1];
    
    
    SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ);
    
    SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
        GPIOPinTypeADC(GPIO_PORTC_BASE,GPIO_PIN_5);
    ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_PROCESSOR, 0);
     ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_CH0 | ADC_CTL_IE |ADC_CTL_END);
    
    ADCSequenceEnable(ADC0_BASE, 3);
    
      ADCIntClear(ADC0_BASE, 3);
    while(1)
    {
    ADCProcessorTrigger(ADC0_BASE, 3);
    
      while(!ADCIntStatus(ADC0_BASE, 3, false))
      {
      }
      ADCIntClear(ADC0_BASE, 3);
    
      ADCSequenceDataGet(ADC0_BASE, 3, ui32ADC0Value); // Watch on ui32ADC0Value
     
    
      SysCtlDelay(20000);
    
    }
    }
    
     
     

    But unfortunately I'm getting random values of ui32ADC0Value that don't correspond to the ambient light .
    What am i doing wrong here ? 

×
×
  • Create New...