Need a Timer with runtime <1ms and need to toggle a Port (P4_3)

⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at//www.wsdof.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
2 posts / 0 new
Last post
SvenHe
Offline
Last seen:3 years 3 months ago
Joined:2017-11-16 09:05
Need a Timer with runtime <1ms and need to toggle a Port (P4_3)

Hello together,

for a function I need a Timer with a 0.1ms runtime. How can i realize such a Timer with the DA14680?
The timers i found have a 1ms runtime.
When the timer is expired, the port P4_3 should toggle and change from high to low or the other way round.
How should this code looks like to steer the P4_3? An example would help me a lot.
I work with the DA14680 Development Board.

Thanking you in anticipation

Sven

Device:
MT_dialog
Offline
Last seen:2 months 4 weeks ago
Staff
Joined:2015-06-08 11:34
Hi SvenHe,

Hi SvenHe,

这取决于你想什么样的计时器和when the timer should operate, the timer modules of the 68x family go to power off state when the device is in sleep mode, meaning that you will have to either keep the device awake while you would like to keep on counting. Also there are the timers of the FreeRTOS implementation which has a granularity of 2 ms, but in that case the device will wake up in order to serve the callback attached to that timer. Regarding the 0.1ms, you wont be able to use the FreeRTOS but you should be able to use the timers of the 68x. You can configure lets say for example timer 0 in order to generate an interrupt or a PWM, you can find an example in the peripherals_demo in how to set the timer up. The function used in order to set the timer up is the timer0_blink_led(), in order to decrease the period of the timer you can set it up to run with the fast clock instead of slow hw_timer0_set_clock_source(HW_TIMER0_CLK_SRC_FAST); and also you can reduce the reload values of the timer using the hw_timer0_set_t0_reload(0x660, 0x660); this will bring you down to a 50% duty cycle PWM signal with a period of 0.2 ms. In order to bind the output of the PWM signal with the timer you will have to configure the specified pin with the PWM functionallity using the hw_gpio_set_pin_function() and assigne the proper ports, pins, set the pin as output and assign the HW_GPIO_FUNC_PWM0 functionallity. Check the snippet below:

hw_gpio_set_pin_function(HW_GPIO_PORT_1, HW_GPIO_PIN_0, HW_GPIO_MODE_OUTPUT, HW_GPIO_FUNC_PWM0);

hw_timer0_init(NULL);
hw_timer0_set_clock_source(HW_TIMER0_CLK_SRC_FAST);
hw_timer0_set_pwm_mode(HW_TIMER0_MODE_PWM); //HW_TIMER0_MODE_CLOCK
hw_timer0_set_t0_reload(0x660, 0x660);
hw_timer0_set_on_clock_div(false);
hw_timer0_enable();

Thanks MT_dialog