Hi AbdulSamad , you should investigate what the “freezing” is. Could there be an exception, that ends in an eternal loop
for(;;)?
Does your function
digitalRead() always succeed? Or does it wait for a condition that sometimes does not occur?
esp if that function happens to be in a different cpp file e.g.
It should not make any difference in which source file a function is located.
Are you using C++ ? That should work OK with FreeRTOS, as long as the compiler knows the linkage type of every function ( C versus C++ ).
C-only headers will often include these statements:
~~~
#ifdef __cplusplus
extern “C” {
#endif
/* Put your C declarations here */
#ifdef __cplusplus
}
#endif
~~~
Mind you that constructors of global and static C++ objects, are being called before
main() is active. If you use the option
nostartfiles, you will have to call the constructors your self. Also make sure that in these constructors, you can not use many resources: for instance the heap has not been set-up yet before
main() is running.
The code that you’re showing is simple and looks good to me.