How to put the desired frequency come from ACLK to a GPIO ?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
qzy_4727816
Level 1
Level 1
5 replies posted First reply posted First question asked

Hi,

Now, I can configure the GPIO successful, but I don't know how to put the desired frequency that come from ACLK. Can you give me some advice? Looking forward to your reply! how to put aclk_output_frequency to GPIO.jpg Have a good day to you!

how to put aclk_output_frequency to GPIO.jpg

0 Likes
1 Solution
SheetalJ
Moderator
Moderator
Moderator
First comment on KBA 750 replies posted 500 likes received

Hi qzy_4727816,

If you look at the parameters of API wiced_hal_aclk_enable(), first parameter is to set the desired output frequency. I would again suggest you to look at /20719-B1_Bluetooth/apps/snip/hal/pwm/hal_pwm.c. Here a GPIO is seletced & configured.

pastedImage_0.png

Desired frequency and other parameters are defined.

pastedImage_1.png

If you right click on the function name and select 'Open Declaration', you will get more details about the function and its parameters.

View solution in original post

5 Replies
SheetalJ
Moderator
Moderator
Moderator
First comment on KBA 750 replies posted 500 likes received

Hi qzy_4727816,

If you look at the parameters of API wiced_hal_aclk_enable(), first parameter is to set the desired output frequency. I would again suggest you to look at /20719-B1_Bluetooth/apps/snip/hal/pwm/hal_pwm.c. Here a GPIO is seletced & configured.

pastedImage_0.png

Desired frequency and other parameters are defined.

pastedImage_1.png

If you right click on the function name and select 'Open Declaration', you will get more details about the function and its parameters.

Hi SheetalJ_96,

Thanks for your reply! Now, I find a following example in a User Guide. I also cannot understand why the clock can maps to the GPIO pin(P28). And I really want to know that whether the divided frequency from ACLK output to a GPIO can only via PWM function?

pwm_aclk.jpg

Have a good day to you!

0 Likes
SheetalJ
Moderator
Moderator
Moderator
First comment on KBA 750 replies posted 500 likes received

Using API wiced_hal_gpio_select_function(), you can configure any GPIO to the required functionality (provided GPIO is not used for any other critical function). Check the snapshot attached in my previous response.

As of now, we have only this option to get the divided frequency. There is no dedicated API or function for the same.

Hi,

As the following example, I want to confirm that why the value of freq not equal to the value (toggle_cnt - init_cnt)?

/// \verbatim

/// UINT16 freq = 256;

/// UINT16 init_cnt = 0xFE55;

/// UINT16 toggle_cnt = 0xFF2A;

/// wiced_hal_gpio_configurePin(28, GPIO_OUTPUT_ENABLE, 0);

/// wiced_hal_aclk_enable(freq, ACLK1, ACLK_FREQ_24_MHZ);

/// wiced_hal_pwm_start(PWM2, PMU_CLK, toggle_cnt, init_cnt, 0);

/// \endverbatim

Thanks.

0 Likes
SheetalJ
Moderator
Moderator
Moderator
First comment on KBA 750 replies posted 500 likes received

I am not sure which user guide you are referring. Please refer pwm example.

0 Likes