https://github.com/kjaxam/gps_clock
This gps clock, satellite view is a test for my Nextion Library
https://github.com/kjaxam/gps_clock
clock cpp20 cubeide dma-idle gps-data gps-library stm32
Last synced: 5 months ago
JSON representation
This gps clock, satellite view is a test for my Nextion Library
- Host: GitHub
- URL: https://github.com/kjaxam/gps_clock
- Owner: KJaxaM
- License: mit
- Created: 2024-12-06T19:59:40.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-10T01:07:09.000Z (about 1 year ago)
- Last Synced: 2025-06-20T14:11:30.054Z (7 months ago)
- Topics: clock, cpp20, cubeide, dma-idle, gps-data, gps-library, stm32
- Language: C++
- Homepage:
- Size: 35.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GPS clock, satellite view
This project is mainly test for my Nextion library [see GitHub](https://github.com/KJaxaM/NextLibCpp). GPS chip produce very exact PPS (±10ns according to datasheet, ±50ns experimentally), so one can build extreme exact clock.
## Hardware
I use STM32 *Nucleo-F446RE* board, GPS breakout board *FGPMMOPA6H* and 3.2″ *Nextion* display.
## Software
Programming language is C++ (compiler GNU v.20) in CubeIDE development tool. I try to use C++ std library both in Nextion library, gps messages parsing and so little \"*low level code*\" as possible.
### Serial reading Rx
Rx both from Nextion and GPS board use DMA with interrupt generated by *Idle*, i.e. you have to call this method:
```C
// Receive an amount of data in DMA mode till either the expected number of data is received or
// an IDLE event occurs.
// huart UART handle.
// pData Pointer to data buffer (uint8_t or uint16_t data elements).
// Size Amount of data elements (uint8_t or uint16_t) to be received.
HAL_StatusTypeDef HAL_UARTEx_ReceiveToIdle_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
```
We do not need an interrupt generated for half full buffer event, suppress it by calling
```C
// change to uart you use
__HAL_DMA_DISABLE_IT(&hdma_uart_rx, DMA_IT_HT);
```
A Idle interrupt is detected by STM32 HAL library callback method:
```C
// Reception Event Callback (Rx event notification called after use of advanced reception
// service).
// huart UART handle
// Size Number of data available in application reception buffer
void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size);
```
### Clock
Clock shows UTC time (for convenience) and is driven by a timer on Nucleo board.
Activities are time separated:
1. -0.5ms: the timer generates interrupt, second variable is increase
2. 0s: pps impulse from GPS generates interrupt
3. after 1ms shows time on the display
4. between 0.1s and 0.45s data from GPS board is read
5. between 0.55s and 0.9s data is processed
The timer's count in pps interrupt is used to alter value of ARR (auto-reload register i.e. number to which timer is counting to).
#### Project site: [https://www.jaxasoft.se/gps_clock/gps_clock.html](https://www.jaxasoft.se/gps_clock/gps_clock.html)
#### My email: