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:
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