cancel
Showing results for 
Search instead for 
Did you mean: 

UART Communication for STM32L4 in KEIL

K_P_D
Associate II
Posted on March 28, 2018 at 14:14

Hi,

I am newbie to this STM32L4 Controller. I am working on GPS device to get the location of the location and i am using the CubeMax and Keil software for programming. As i have mention that i am newbie, I dont know how do I move forward.

I want to Learn the programming in Keil and with their HAL Drive and all. I am using the UART-2 in STM32L4 controller to communicate between the GPS and controller. Here I have used the UART HAL Driver for communication, but i properly dont know that how i should pass argument i that HAL driver function for communication. 

So please share and guide for this UART Communication using HAL Driver in keil. And also share if their is any study material available for this.

I my code HALL function defined like this:

'HAL_UART_Transmit(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout);'

And i have pass the argument like this:

'HAL_UART_Transmit(&huart2 ,(uint8_t*)&buffer,20,1000); '

In buffer i have assigned the AT+QGPSCFG to send the AT command to communicate between the GPS and the Controller.  If their is any problem in code please let me know.

Please share me the proper details for this.

Thanks 

Sachin

13 REPLIES 13
Posted on March 28, 2018 at 14:43

Cross-posted here

http://www.keil.com/forum/63479/

 

>> If their is any problem in code please let me know.

You've showed a single line, you should perhaps be using strings, and only sending the actual length of the viable data rather than arbitrary length.

GPS receivers typically don't take AT commands, so presume you have a MODEM with a GPS connected. You need to automate the interaction, ie sending commands and parsing and processing responses.

A lot of this is basic programming rather than being Keil or STM32 specific. You should perhaps focus on general tutorials, and work through all the code examples under the STM32 HAL source trees. Lots of book available of programming, get comfortable with that.

This is a handler that collects whole GPS NMEA sentences and then passes them off. The USART typically receives a character at a time so you either need to accumulate multiple bytes, or use a state machine.

https://community.st.com/message/181151-implementing-interrupt-driven-stream-uart-rx-handling-on-l4

 
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Andrew Neil
Evangelist III
Posted on March 28, 2018 at 19:33

I am newbie to this STM32L4 Controller.

So do you have any prior experience with any other microcontroller(s) ?

Or with 'C' programming in general?

Did you study  the learning resources suggested in your cross-post on the Keil forum?

Posted on March 29, 2018 at 07:47

Hi Andrew Neil,

                            Yes, I am experienced with the micro-controller as well as with C language.

Not yet, for now i am started to read the suggested resources from cross post.

Posted on March 29, 2018 at 08:09

The original post was too long to process during our migration. Please click on the provided URL to read the original post. https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I6tN&d=%2Fa%2F0X0000000bxT%2FFkCx5NUNJfeJaytTdclXgIPPKY4DC.KSg6FXEBjemAs&asPdf=false
Posted on March 29, 2018 at 08:43

I have read the AT commands for the GPS operation. They mention so many commands for the many operation like configuration, get location and many others also.

Are you sure you don't mix up things here ?

GPS modules don't take AT commands, they use the NMEA 183 standard (or the newer NMEA 2000).

And the have a default setting (baudrate, update rate, sentences sent), i.e. the work 'out of the box', without configuration.

I would suggest to concentrate on RX first, use these GPS default settings, and see if you get the sentences.

Tackle more complex things later.

Posted on March 29, 2018 at 09:52

AvaTar wrote:

GPS modules don't take AT commands

As

Turvey.Clive.002

‌ suggested, this probably means that the OP has some kind of (cellular?) modem which

integrates a GPS.

It would have been helpful if the OP had confirmed that - and even stated what unit is being used!

Googling the

'AT+QGPSCFG' mentioned in the OP suggests that it may be a Quectel UC20 ...

Posted on March 29, 2018 at 09:55

sachin singh wrote:

It will be great if can suggest me any good 

available

book for the programming. 

Again, these have already been given in your cross-post on the Keil forum.

And i want to use normal HAL Driver functions of Keil. 

The HAL is an ST thing - it has nothing to do with Keil.

Posted on March 29, 2018 at 10:13

I have read this, however, the OP was not really clear about his hardware.

Googling the

'AT+QGPSCFG' mentioned in the OP suggests that it may be a Quectel UC20 ...

Sound like a suboptimal hardware choice in light of this:

I am newbie to this STM32L4 Controller. ...  As i have mention that i am newbie, I dont know how do I move forward.

I want to Learn the programming in Keil and with their HAL Drive and all.

Posted on March 29, 2018 at 10:43

Okay