Hello,
Recently,I have a project which used the Jetson connection with a microcontroller.And then I need a square wave,can we make some chaneged in dtb file to set a GPIO to generate a square wave?
hello qinyyuu,
may I have your confirmation about what’s the use-case that need a square wave.
I think you should be able to modify the linux kernel to program the GPIO high/low period to generate a square wave.
below general functions should be helpful.
sources/kernel/kernel-4.4/arch/arm/include/asm/gpio.h
#define gpio_get_value __gpio_get_value
#define gpio_set_value __gpio_set_value
Hello JerryChang,
I need a 1 MHz square wave as a signal source to monitor whether the system is running normally. Can you modify the implementation through the device tree? Is the kernel modified in a device-driver or other way?
hello qinyyuu,
I didn’t have experience to generate a square wave before,
you could try to modify the device driver and have implementation to program the GPIO high/low period to generate a square wave.
thanks
FYI, device tree can set up the GPIO to make it an output and be sure it is ready for a driver owned by you, but the device tree itself is not a timer (the device tree isn’t even a driver…it’s more or less a configuration the drivers read to match generic concepts to how a specific hardware configures to match the concept). Once the device tree reserves that GPIO for you to use you’ll still need to write a kernel driver capable of switching between 1 and 0 at the correct rate.
If you want to do a square wave, just set up a timer (e.g. 10ms) to set the GPIO output
(psuedocode)
Timer_task10ms //Thread function
{
while (timer_task)
{
if (current_gpio_state == 0)
{
gpioSetValue(j21_pin18, 1);
}
else if (current_gpio_state == 1)
{
gpioSetValue(j21_pin18, 0);
}
else
{
// Leave alone this time
}
}
}