Half Second Timer needed - read GPIO for every Half second

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Half Second Timer needed - read GPIO for every Half second

ソリューションへジャンプ
2,734件の閲覧回数
TVNAIDU
Contributor III

Need to add smal pioece of code to read GPIO for every Half second code, any timer I can invoke from task to read fro every Half-second?.

 

appreciated.

ラベル(1)
0 件の賞賛
返信
1 解決策
1,673件の閲覧回数
TVNAIDU
Contributor III
Thanks Yevgeni. appreciated.

元の投稿で解決策を見る

0 件の賞賛
返信
7 返答(返信)
1,673件の閲覧回数
admin
Specialist II

For interval of half a second, 32-bit timer needs to be used.

 

Alternatively, you can count the OS ticks (the default is 50 ms).

 

0 件の賞賛
返信
1,673件の閲覧回数
TVNAIDU
Contributor III

Thanks, can I crwate a separate task for this, in main function in for loop, can I use tk_sleep for Half second, that way, task collects data for every Half second.

 

task_main_fn()

{

 

      for(;:smileywink: {

       collect GPIO data and do process....

      tk_sleep(half-second);

      }

 

}

0 件の賞賛
返信
1,673件の閲覧回数
admin
Specialist II
Yes, it is the simplest solution: the dedicated task, which reads and processes GPIO and then sleeps for half a second.
0 件の賞賛
返信
1,674件の閲覧回数
TVNAIDU
Contributor III
Thanks Yevgeni. appreciated.
0 件の賞賛
返信
1,673件の閲覧回数
TVNAIDU
Contributor III

Hi Yevgeni:

 

I have to take 840 samples per second, if I keep for loop for 840 then if I keep tk_sleep, not sure when it finishes, for example I have to measure 24 receptacles instantaneous current and voltage for 840 samples per second, is there any way I can measure makesure 840 samples can take within one second, can I use times to happen 840 samples per second exactly without putting task in sleep using tk_sleep?

0 件の賞賛
返信
1,673件の閲覧回数
admin
Specialist II

TVNAIDU,

let discuss sampling the analog values in the separate thread.

Coukd you, please, open the new thread with the descriptive name?

 

0 件の賞賛
返信
1,673件の閲覧回数
TVNAIDU
Contributor III

Yes yevgenit, I opened another thread "Sampling of Analog values". Please take a look.

 

thanks.

0 件の賞賛
返信