Quantcast
Channel: Microcontrollers
Viewing all articles
Browse latest Browse all 215990

Forum Post: RE: cc2530 znp using getvcc3 for analog input

$
0
0

[quote user="nischal venugopal"]HOW DO I SHORTEN IT?? [/quote]

No idea. The code you posted doesn’t show all the initialization. Also, I don’t know what the HAL functions are doing.

But I noticed some things in your state machine.

Some states simply switch from one state to the next. The two states could as well be joined, since after leaving the switch, you immediately loop back into it. Separate states that are simply sequentially executed make no sense (you could assign a separate state to each single instruction as well then).

Also, some of you states have while loops. That’s also nothing that should be done in a state machine. If you cannot proceed, exit the state and later return to it for another try. You either change the state or you keep the same state, but you don’t loop inside the state ..

Maybe some of your code inside the states introduces a delay. You cannot start a send process if the state machine isn’t at the proper state, no matter when the trigger comes.

Take a look at the state diagrams in the users guide for inspiration. Each bubble is a state, and each arrow leaves the code block of this state (and therefore the switch case) even if it returns back to the same bubble on next loop.
And if you need to wait for a trigger and nothing else can be done in the meantime, enter LPM0 and let an ISR wake you when the trigger comes.


Viewing all articles
Browse latest Browse all 215990

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>