Because of the holidays, TI E2E™ design support forum responses will be delayed from Dec. 25 through Jan. 2. Thank you for your patience.

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.

How to send AT Commands from TM4C123GXL to ESP8266

Hi to all of you!

I need to send AT commands from the Launchpad TM4C123GXL to the Wi-Fi module ESP8266, through the UART.

How can i achieve this?

Basic AT Commands are like AT+GMR or AT+SLEEP, for example, and they must terminate with \r\n,

where: \r = carriage return and \n = new line.

Is there a direct way to send them like a string (from the uC to the ESP8266), or have I to send the ASCII code of each letter?

I'm confused.

  • Hello RainBow,

    The Search tool on the top of the forum is a useful utility.

    e2e.ti.com/.../420210

    Regards
    Amit
  • Thanks a lot for your help, Amit!

    I' ve downloaded the . zip file in the link above and now I'm watching to the "main.c" file.

    I think that the "SendATCommand" function is what I was searching for.

    Here there is the "function body":

    void SendATCommand(char *cmd)
    {
    	while(UARTBusy(UART1_BASE));
    	while(*cmd != '\0')
    	{
    		UARTCharPut(UART1_BASE, *cmd++);
    	}
    	UARTCharPut(UART1_BASE, '\r'); //CR
    	UARTCharPut(UART1_BASE, '\n'); //LF
    
    }
    

    And here there is an example of the "function call":

    SendATCommand("AT");

    As I can see, the function waits until the UART transmitter isn't busy.

    When it' s free, the function sends the AT command through the while-loop, until it meets the NULL character '\0', which it isn't part of the AT Commands, so it indicates that the AT Command is terminated.

    Then, SendATCommand() sends '\r' and '\n' as required in the ESP8266 documentation.

    But, now I' ve a doubt: How the while-loop, in the specific terms, works?

    I know that UARTCharPut() sends a character, so I think that in the first calling it sends "A" and then, in the second calling, (since *cmd is incremented) it sends "T"..is it right?

    I also know that UARTCharPut() sends the [7:0] bits of the UART Data Register (UARTDR).

    So, here my question: how is, for example, the letter "A" stored in these [7:0] bits of the UARTDR register?

    I guess that, since I've found that (in the ASCII table) the Hex value corresponding to the letter "A" is 0x41, I suppose that the letter "A" is stored, in the UARTDR register, as 0100 0001, but I'm not sure of my reasoning.

    Could you help me to understand if I'm right, or if I'm wrong?

  • Hello RainBow,

    Processors do not understand anything but binary. So if the character 'A' has to be sent then it would store the Binary/Hex Represntation of the ASCII character,

    Regards
    Amit
  • Note that you are both right - Character "A" is stored as 0x41 - and indeed the MCU has concern for the most efficient data form - binary.

    Our colorful poster has more than enough info to commence in experimentation - the MCU and competent IDE provide unmatched learning tools. (sometimes it pays to look beyond the (rainbow).
  • Amit Ashara said:
    Processors do not understand anything but binary. So if the character 'A' has to be sent then it would store the Binary/Hex Represntation of the ASCII character

    Ok. So I deduce that what I wrote in the post here above is correct :)

    cb1- said:
    Our colorful poster has more than enough info to commence in experimentation - the MCU and competent IDE provide unmatched learning tools. (sometimes it pays to look beyond the (rainbow)

    Yes, you' re right  :)

    But for these few days I haven't the launchpad with me, so I have another question.

    I' ve noted that the prototype of this function is:

    void UARTCharPut(uint32_t ui32Base, unsigned char ucData);

    So, my question, are these three rows:

    UARTCharPut(UART1_BASE, 'A');
    
    UARTCharPut(UART1_BASE, 0x41); // hex ASCII-value of 'A'
    
    UARTCharPut(UART1_BASE, 65); // dec ASCII-value of 'A'

    equivalent with each other?

    Thanks again to both of you!

  • Hello RainBow

    Yes, they are equivalent

    Regards
    Amit
  • Ok, perfect.

    Thanks a lot.
  • Hello RainBow,

    You may also look at the assembly code for the same. It should generate the same literal pool.

    Regards
    Amit
  • Indeed they're the same. (just as Amit noted)

    It helps us to maintain a small "ASCII" chart - which relates the various "chars" to their "real world" meaning & values. Having this handy saves repeated searches...