Jump to content

RAKSH

Members
  • Content Count

    19
  • Joined

  • Last visited

  • Days Won

    1

Reputation Activity

  1. Like
    RAKSH got a reaction from austen520 in Analog to Digital Conversion on Tiva C Series MCU   
    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 .
     
  2. Like
    RAKSH got a reaction from gcshyamsundhar in Analog to Digital Conversion on Tiva C Series MCU   
    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. Like
    RAKSH reacted to spirilis in [Energia Library] Nordic nRF24L01+ library   
    Oh, yeah, you do have to set the TX address. That has no effect on the RX address fyi.
     
    Sent from my Galaxy Note II with Tapatalk 4
     
     
  4. Like
    RAKSH reacted to spirilis in [Energia Library] Nordic nRF24L01+ library   
    And for the 2nd post, yes that should work.
     
    Sent from my Galaxy Note II with Tapatalk 4
     
     
  5. Like
    RAKSH reacted to pao in ADC on Tiva C Series   
    HI @
    Which your Microcontroller ?  Do you have 'Tiva C Series LaunchPad ( EK-TM4C123GXL) ?
     
     
    if you have 'Tiva C Series LaunchPad', you can connect pin 'PE3'
     
    GPIO_PORTC_BASE ==> GPIO_PORTE_BASE
     
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
    GPIOPinTypeADC(GPIO_PORTE_BASE,GPIO_PIN_3);
    ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_PROCESSOR, 0);
    ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_CH0 | ADC_CTL_IE |ADC_CTL_END);
  6. Like
    RAKSH got a reaction from bluehash in New CCS project which has UART functions included from UARTStdio.h   
    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 . 
  7. Like
    RAKSH reacted to roches in [Energia Library] Nordic nRF24L01+ library   
    @ RAKSH:
     
    Change line 6 in:
     
    Enrf24 radio(PE_1, PE_2, PE_3); // PE_1 = CE, PE_2 = CSN, PE_3 = IRQ
     
    The Stellaris doesn't know pin P1_0 ....
     
    Roche
     
    Added my RXdemo for you...  FOR THE STELLARIS LAUNCHPAD LM4F120H5Q
    Enrf24_RXdemo.ino
×
×
  • Create New...