CPU halting when working with timeval, gettimeofday()
Posted: Thu Aug 31, 2017 2:43 am
Hi, I am trying to run a simple timer program to print to COM ever so many milliseconds. Code compiles just fine but when i run i get a CPU halted error , " Guru Meditation Error of type LoadProhibited occurred on core 1. Exception was unhandled." I know it has to be a simple problem (im learning).
Code: Select all
#include <sys/time.h>
timeval *past_time;
timeval *current_time;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
gettimeofday(past_time, NULL);
}
void loop() {
// put your main code here, to run repeatedly:
gettimeofday(current_time, NULL);
if((current_time->tv_usec - past_time->tv_usec) > 2000)
{
Serial.println(analogRead(32));
gettimeofday(past_time, NULL);
}
}