87 lines
3.1 KiB
Arduino
87 lines
3.1 KiB
Arduino
/*
|
|
Time Pulse Parameters
|
|
By: Paul Clark (PaulZC)
|
|
Date: January 13th, 2021
|
|
|
|
License: MIT. See license file for more information but you can
|
|
basically do whatever you want with this code.
|
|
|
|
This example shows how to change the time pulse parameters and configure the TIMEPULSE (PPS)
|
|
pin to produce a 1kHz squarewave
|
|
|
|
Feel like supporting open source hardware?
|
|
Buy a board from SparkFun!
|
|
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
|
|
NEO-M8P RTK: https://www.sparkfun.com/products/15005
|
|
SAM-M8Q: https://www.sparkfun.com/products/15106
|
|
|
|
Hardware Connections:
|
|
Plug a Qwiic cable into the GNSS and a BlackBoard
|
|
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
|
|
Open the serial monitor at 115200 baud to see the output
|
|
*/
|
|
|
|
#include <Wire.h> //Needed for I2C to GNSS
|
|
|
|
#include "SparkFun_u-blox_GNSS_Arduino_Library.h" //http://librarymanager/All#SparkFun_u-blox_GNSS
|
|
SFE_UBLOX_GNSS myGNSS;
|
|
|
|
void setup()
|
|
{
|
|
Serial.begin(115200);
|
|
while (!Serial)
|
|
; //Wait for user to open terminal
|
|
Serial.println(F("SparkFun u-blox Example"));
|
|
|
|
Wire.begin();
|
|
|
|
//myGNSS.enableDebugging(); // Uncomment this line to enable debug messages
|
|
|
|
if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port
|
|
{
|
|
Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing."));
|
|
while (1)
|
|
;
|
|
}
|
|
|
|
myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
|
|
|
|
// Create storage for the time pulse parameters
|
|
UBX_CFG_TP5_data_t timePulseParameters;
|
|
|
|
// Get the time pulse parameters
|
|
if (myGNSS.getTimePulseParameters(&timePulseParameters) == false)
|
|
{
|
|
Serial.println(F("getTimePulseParameters failed! Freezing..."));
|
|
while (1) ; // Do nothing more
|
|
}
|
|
|
|
timePulseParameters.tpIdx = 0; // Select the TIMEPULSE pin
|
|
//timePulseParameters.tpIdx = 1; // Or we could select the TIMEPULSE2 pin instead, if the module has one
|
|
|
|
// We can configure the time pulse pin to produce a defined frequency or period
|
|
// Here is how to set the frequency:
|
|
timePulseParameters.freqPeriod = 1000; // Set the frequency/period to 1000Hz
|
|
timePulseParameters.pulseLenRatio = 0x80000000; // Set the pulse ratio to 2^31 * 2^-32 to produce 50:50 mark:space
|
|
|
|
timePulseParameters.flags.bits.active = 1; // Make sure the active flag is set to enable the time pulse. (Set to 0 to disable.)
|
|
timePulseParameters.flags.bits.isFreq = 1; // Tell the module that we want to set the frequency (not the period)
|
|
timePulseParameters.flags.bits.isLength = 0; // Tell the module that pulseLenRatio is a ratio / duty cycle (2^-32) - not a length (in us)
|
|
timePulseParameters.flags.bits.polarity = 0; // Tell the module that we want the falling edge at the top of second. (Set to 1 for rising edge.)
|
|
|
|
// Now set the time pulse parameters
|
|
if (myGNSS.setTimePulseParameters(&timePulseParameters) == false)
|
|
{
|
|
Serial.println(F("setTimePulseParameters failed!"));
|
|
}
|
|
else
|
|
{
|
|
Serial.println(F("Success!"));
|
|
}
|
|
}
|
|
|
|
void loop()
|
|
{
|
|
// Nothing to do here
|
|
}
|