Ok,
I want to document this madness for anyone that tries to venture down this same path. After some more playing with the timers, it looks like I made a mistake assuming that the timer had overflowed. It was my unsigned long that had overflowed. As I have heard it said if you assume something, you'll make yourself look like the first three letters of assume.
Anyway, the code I used to test this is below but it looks like the timer1 is at least 8 bytes. My uint64_t overflow there also, and I get an error with uint128_t. So I can't go any bigger. I suppose there is a way to go bigger but I'm not aware of how. If anyone knows I would be interested.
uint64_t cycle_time = 0;
int last_bytte = -1;
void cycle_I()
{
noInterrupts();
int bytte = 0;
uint64_t current_cycle = cycle_time;
cycle_time = cycle_time << 8; // Shift one byte over
cycle_time += B11111111; // Add one more byte
while (current_cycle != 0)
{
bytte++;
current_cycle = current_cycle >> 8;
}
if (bytte == last_bytte)
{
Serial.print("The timer has stopped incressing at ");
Serial.print(last_bytte);
Serial.println(" bytes.");
}
timer1_write(cycle_time);
Serial.print("Trying "); Serial.print(bytte); Serial.println(" bytes.");
last_bytte = bytte;
interrupts();
}
void setup() {
Serial.begin(115200);
while(!Serial);
delay(5*1000);
Serial.print("Size of varible being used is ");
Serial.println(sizeof(cycle_time));
timer1_attachInterrupt(cycle_I);
timer1_isr_init();
//TIM_DIV1 = 0, //80MHz (80 ticks/us - 104857.588 us max)
//TIM_DIV16 = 1, //5MHz (5 ticks/us - 1677721.4 us max)
//TIM_DIV256 = 3 //312.5Khz (1 tick = 3.2us - 26843542.4 us max)
timer1_enable(TIM_DIV16, TIM_EDGE, TIM_SINGLE);
cycle_I();
}
void loop() { ; }