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.

TM4C123GH6PM: Need a flowchart just like page 1010 in datasheet on how to code register algorithm

Part Number: TM4C123GH6PM

Hi,

I have a customer who needs a flowchart just like page 1010 in the datasheet of TM4C123GH6PM on how to code register algorithm.

Customer already create his own library for gpio, spi, i2c and uasrt using RTVA TM4C123GH6PM but he need a instructions or flowchart like in page 1010 in datasheet for coding adc, timer, etc.

I hope you can help our customer with his query. Thank you very much.

Best Regards,

Ray Vincent

  • Hi Ray,

      There is no such flowcharts for other modules. I can understand such flowchart maybe useful particularly for I2C module as shown in page 1010 because the sequence of steps is important for the I2C to work correctly. Even for I2C, the TivaWare API will abstract the flowchart for users.  I don't think such flowcharts is needed for other modules. For timer and ADC, it is just matter of configuring some control registers and then enable the modules. There is no real requirement on which control register must be programmed first and which one is second and third and so forth. Normally, the last step is to enable the module. You can ask your customer to refer to the TivaWare ADC and Timer examples for reference. 

  • Hi Charles,

    Good Day. Please see below the response from our customer. Thanks.

    • They said you dont need to follow orders before activating the system but i am asking for some register has to be check for system is working or not because of this reason i dont want to read all registers before writing programs. Lets make an example for systick

      There is follow line in here and than codes generates an interrupt. As you know after getting inside an interrupt we have to clear interrupt but which register hasto be cleared. i dont want to check all staff.
      void Sys_Tick_Init(uint8_t Load_Value){
      //disable systick
      SysTick->CTRL&=0;
      Interrupt_IRQ_Config(SysTick_IRQn,ENABLE_);
      IRQ_Number_Priorty(SysTick_IRQn,PRIORITY_NO_7);

      //deger yazilacak ama interrrupt kullandigim için 1 degil 12 çikaracam
      SysTick->LOAD =Load_Value-12;
      SysTick->VAL=0;
      SysTick->CTRL|=7;

      }
    • Here you can see. I clear register of ICSR of 25. bit must be cleared to release the interrupt cycle. I dont want to check all register give me a short documentation for peripherals. This is the point why i am asking a help. I hope i can tell what my problem is. Thank you. Have a good day..

      void Systick_handler(void){
      // systick disable
      SysTick->CTRL&=0;
      //interruptflagi temizlenmeli

      SCB->ICSR|=1<<25;

      // BURADAKI DEGISKENLER VOLATILE OLMALI BU ONEMLI ve global olmali
      asd++;
      }
      Best Regards,
      Ray Vincent
  • Hi,

     I don't quite understand what your customer is asking for what help. Is the problem specific to the SysTick module? In his Systick_handler he tries to disable the Systick module. There is no need to do that in my opinion. The SysTick is a timer module and it periodically generates interrupt. In the interrupt, it is all up to the application what needs to be done. He can just clear the interrupt bit by SCB->ICSR|=1<<25. 

      As for other modules, in the interrupt ISR the application will normally find out what caused the interrupt and then clear the interrupt status flags. In TivaWare, you will call xxxIntStatus() to find out what caused the interrupt and then call xxxIntClear() to clear the interrupt flags. For example, you will call TimerIntStatus() to find out what caused the timer to interrupt (e.g. match, timeout, etc) and then call TimerIntClear() to clear the interrupt flags.

      Again, I don't understand why you customer wants to build his own driver when there is a proven and easy to use TivaWare driver that is ready to use and be supported by us. We cannot support custom drivers. 

  • Hi Charles,

    Good Day. Please see below the response of our customer to your response.

    I try to explain for every peripherals some register must be controlled, set or cleared to understand which registers has to be used for controller I don't want to check all of them instead of checking I need an explanation such as guide line or flow chart I know how to enable peripherals but some times we have to check specific register as I mentioned above.

    Best Regards,

    Ray Vincent

  • Hi Ray,

      Sorry, I really don't know how to help you here. As I mentioned in my very first reply, there is no such thing as a flowchart as to what registers to set and clear for each peripherals. There is however in the datasheet descriptions on how to initialize peripherals. You just need to go to the respective peripherals to see the description. For example, in the datasheet, for the SPI module you will find below description on how to configure the registers. I hope this helps. If this is not what you are looking for then we really hope you can just follow the the TivaWare peripheral drivers and the various examples in the TivaWare library. 

    15.4 Initialization and Configuration
    To enable and initialize the SSI, the following steps are necessary:
    1. Enable the SSI module using the RCGCSSI register (see page 346).
    2. Enable the clock to the appropriate GPIO module via the RCGCGPIO register (see page 340).
    To find out which GPIO port to enable, refer to Table 23-5 on page 1351.
    3. Set the GPIO AFSEL bits for the appropriate pins (see page 671). To determine which GPIOs to
    configure, see Table 23-4 on page 1344.
    4. Configure the PMCn fields in the GPIOPCTL register to assign the SSI signals to the appropriate
    pins. See page 688 and Table 23-5 on page 1351.
    5. Program the GPIODEN register to enable the pin's digital function. In addition, the drive strength,
    drain select and pull-up/pull-down functions must be configured. Refer to “General-Purpose
    Input/Outputs (GPIOs)” on page 649 for more information.
    Note: Pull-ups can be used to avoid unnecessary toggles on the SSI pins, which can take the
    slave to a wrong state. In addition, if the SSIClk signal is programmed to steady state
    High through the SPO bit in the SSICR0 register, then software must also configure the
    GPIO port pin corresponding to the SSInClk signal as a pull-up in the GPIO Pull-Up
    Select (GPIOPUR) register.
    For each of the frame formats, the SSI is configured using the following steps:
    1. Ensure that the SSE bit in the SSICR1 register is clear before making any configuration changes.
    2. Select whether the SSI is a master or slave:
    a. For master operations, set the SSICR1 register to 0x0000.0000.

    b. For slave mode (output enabled), set the SSICR1 register to 0x0000.0004.
    c. For slave mode (output disabled), set the SSICR1 register to 0x0000.000C.
    3. Configure the SSI clock source by writing to the SSICC register.
    4. Configure the clock prescale divisor by writing the SSICPSR register.
    5. Write the SSICR0 register with the following configuration:
    ■ Serial clock rate (SCR)
    ■ Desired clock phase/polarity, if using Freescale SPI mode (SPH and SPO)
    ■ The protocol mode: Freescale SPI, TI SSF, MICROWIRE (FRF)
    ■ The data size (DSS)
    6. Optionally, configure the SSI module for μDMA use with the following steps:
    a. Configure a μDMA for SSI use. See “Micro Direct Memory Access (μDMA)” on page 585 for
    more information.
    b. Enable the SSI Module's TX FIFO or RX FIFO by setting the TXDMAE or RXDMAE bit in the
    SSIDMACTL register.
    7. Enable the SSI by setting the SSE bit in the SSICR1 register.
    As an example, assume the SSI must be configured to operate with the following parameters:
    ■ Master operation
    ■ Freescale SPI mode (SPO=1, SPH=1)
    ■ 1 Mbps bit rate
    ■ 8 data bits
    Assuming the system clock is 20 MHz, the bit rate calculation would be:
    SSInClk = SysClk / (CPSDVSR * (1 + SCR))
    1x106 = 20x106 / (CPSDVSR * (1 + SCR))
    In this case, if CPSDVSR=0x2, SCR must be 0x9.
    The configuration sequence would be as follows:
    1. Ensure that the SSE bit in the SSICR1 register is clear.
    2. Write the SSICR1 register with a value of 0x0000.0000.
    3. Write the SSICPSR register with a value of 0x0000.0002.
    4. Write the SSICR0 register with a value of 0x0000.09C7.
    5. The SSI is then enabled by setting the SSE bit in the SSICR1 register.

  • Hi Charles,

    Good Day. Please see below the response of our customer to your suggestion. Thanks.

    Ok i know datasheet how to initialize peripheral i print datasheet and read it. I think we are inside in a closed loop. As I mentioned from the beginning . I know how to enable peripheral. when you read datasheet can you show me how to read uart peripheral or spi peripheral etc. You can not show me. I sent you an closed loop uart send data C function.
    Can you show me any example for how to read, write of peripheral except initialization chapter in datasheet?
    You may not show because I read all datasheet and i couldn't find it.

    Best Regards,

    Ray Vincent

  • I sent you an closed loop uart send data C function.

    What uart send data C function? When did you send? I don't see any  uart  C function in any of your prior replies? I think we have a communication problem.  I don't really understand your meaning of "closed-loop".

    There is TivaWare example on UART. If you want to see how UART works then look at the example and look at the source code of the API how the registers are used. 

    #include <stdint.h>
    #include <stdbool.h>
    #include "inc/hw_ints.h"
    #include "inc/hw_memmap.h"
    #include "driverlib/debug.h"
    #include "driverlib/fpu.h"
    #include "driverlib/gpio.h"
    #include "driverlib/interrupt.h"
    #include "driverlib/pin_map.h"
    #include "driverlib/rom.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/uart.h"
    
    //*****************************************************************************
    //
    //! \addtogroup example_list
    //! <h1>UART Echo (uart_echo)</h1>
    //!
    //! This example application utilizes the UART to echo text.  The first UART
    //! (connected to the USB debug virtual serial port on the evaluation board)
    //! will be configured in 115,200 baud, 8-n-1 mode.  All characters received on
    //! the UART are transmitted back to the UART.
    //
    //*****************************************************************************
    
    //*****************************************************************************
    //
    // The error routine that is called if the driver library encounters an error.
    //
    //*****************************************************************************
    #ifdef DEBUG
    void
    __error__(char *pcFilename, uint32_t ui32Line)
    {
    }
    #endif
    
    //*****************************************************************************
    //
    // The UART interrupt handler.
    //
    //*****************************************************************************
    void
    UARTIntHandler(void)
    {
        uint32_t ui32Status;
    
        //
        // Get the interrrupt status.
        //
        ui32Status = ROM_UARTIntStatus(UART0_BASE, true);
    
        //
        // Clear the asserted interrupts.
        //
        ROM_UARTIntClear(UART0_BASE, ui32Status);
    
        //
        // Loop while there are characters in the receive FIFO.
        //
        while(ROM_UARTCharsAvail(UART0_BASE))
        {
            //
            // Read the next character from the UART and write it back to the UART.
            //
            ROM_UARTCharPutNonBlocking(UART0_BASE,
                                       ROM_UARTCharGetNonBlocking(UART0_BASE));
    
            //
            // Blink the LED to show a character transfer is occuring.
            //
            GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, GPIO_PIN_2);
    
            //
            // Delay for 1 millisecond.  Each SysCtlDelay is about 3 clocks.
            //
            SysCtlDelay(SysCtlClockGet() / (1000 * 3));
    
            //
            // Turn off the LED
            //
            GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 0);
    
        }
    }
    
    //*****************************************************************************
    //
    // Send a string to the UART.
    //
    //*****************************************************************************
    void
    UARTSend(const uint8_t *pui8Buffer, uint32_t ui32Count)
    {
        //
        // Loop while there are more characters to send.
        //
        while(ui32Count--)
        {
            //
            // Write the next character to the UART.
            //
            ROM_UARTCharPutNonBlocking(UART0_BASE, *pui8Buffer++);
        }
    }
    
    //*****************************************************************************
    //
    // This example demonstrates how to send a string of data to the UART.
    //
    //*****************************************************************************
    int
    main(void)
    {
        //
        // Enable lazy stacking for interrupt handlers.  This allows floating-point
        // instructions to be used within interrupt handlers, but at the expense of
        // extra stack usage.
        //
        ROM_FPUEnable();
        ROM_FPULazyStackingEnable();
    
        //
        // Set the clocking to run directly from the crystal.
        //
        ROM_SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
                           SYSCTL_XTAL_16MHZ);
    
        //
        // Enable the GPIO port that is used for the on-board LED.
        //
        ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
    
        //
        // Enable the GPIO pins for the LED (PF2).
        //
        ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2);
    
        //
        // Enable the peripherals used by this example.
        //
        ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
        ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    
        //
        // Enable processor interrupts.
        //
        ROM_IntMasterEnable();
    
        //
        // Set GPIO A0 and A1 as UART pins.
        //
        GPIOPinConfigure(GPIO_PA0_U0RX);
        GPIOPinConfigure(GPIO_PA1_U0TX);
        ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
    
        //
        // Configure the UART for 115,200, 8-N-1 operation.
        //
        UARTConfigSetExpClk(UART0_BASE, ROM_SysCtlClockGet(), 115200,
                                (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
                                 UART_CONFIG_PAR_NONE));
    
        //
        // Enable the UART interrupt.
        //
        ROM_IntEnable(INT_UART0);
        ROM_UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT);
    
        //
        // Prompt for text to be entered.
        //
        UARTSend((uint8_t *)"\033[2JEnter text: ", 16);
    
        //
        // Loop forever echoing data through the UART.
        //
        while(1)
        {
        }
    }
    

  • Hi Charles,

    I'm sorry, I thought I send to you the closed loop uart send data C function from the customer. Since the customer email address is not allowed to post in E2E, I'm only share what we have discuss on our side. Please bear with me but I am willing to support both you and the customer so that we can help the query of the customer. Below is the closed loop uart send data C function. Thank you very much for your support. Even though this is a hard one, I really really appreciate your help.

    Another example for closed loop uart send data function.
    1)First i checked data length
    2)Second Fifo full
    3) last check is Fifo empty.

    For every peripheral we have to check some register as you can see.Only thing i am asking you guide line or flow chart for processor which has special properties.


    void UART_Recive_Data(USART_Handle_t *pUART_Handle, uint8_t *pRxBuffer, uint32_t Len){
    while(Len>0)
    {
    while(UART_Flag_Status(pUART_Handle,RECIVE_FIFO_FULL)==0)
    {}
    *pRxBuffer|=pUART_Handle->pUSARTx->DR;
    pRxBuffer++;
    Len--;
    while(UART_Flag_Status(pUART_Handle,RECIVE_FIFO_EMPTY)!=0){}
    }

    }

    Best Regards,

    Ray Vincent

  • Hi Ray,

      Why do you want to wait for the FIFO_FULL flag to set to continue as in your below line? Let's say your Len=5 but the FIFO is not full so you will just keep waiting. If the transmitter doesn't send you any more data then you will just wait in this line forever because the FIFO is not full yet. 

    while(UART_Flag_Status(pUART_Handle,RECIVE_FIFO_FULL)==0)
    {}

    I will suggest you just check for FIFO_EMPTY flag. If the FIFO is not empty then keep reading from the FIFO until either you reach the Len or the FIFO becomes empty. As I mentioned there are TivaWare examples that you can reference. In this uart_echo example, the UARTIntHandler ISR just loop while there are characters in the receive FIFO. It keeps reading the FIFO and then transmit what is received until the FIFO becomes empty. 

    void
    UARTIntHandler(void)
    {
        uint32_t ui32Status;
    
        //
        // Get the interrrupt status.
        //
        ui32Status = MAP_UARTIntStatus(UART0_BASE, true);
    
        //
        // Clear the asserted interrupts.
        //
        MAP_UARTIntClear(UART0_BASE, ui32Status);
    
        //
        // Loop while there are characters in the receive FIFO.
        //
        while(UARTCharsAvail(UART0_BASE))
        {
            //
            // Read the next character from the UART and write it back to the UART.
            //
            UARTCharPutNonBlocking(UART0_BASE,
                                       MAP_UARTCharGetNonBlocking(UART0_BASE));
    
    
        }
    }

  • Hi Charles,

    Good Day. I send to you to a private message a video from our customer. Please help to check it out.

    Best Regards,

    Ray Vincent

  • Hi Ray,

     I replied to you in PM.