Hi,
I would like to use Timer1 of Digispark (ATTiny85). The problem is this timer is used for generating millis(). I have found
#define TIMER_TO_USE_FOR_MILLIS 1
in /cores/tiny/core_build_options.h and changing this to 0 will correctly change the millis to Timer0. But this changes behavior for all digispark sketches. I would like to change it only for this one (so I don't break the other). Is there some way to do this? When my sketch runs it is already defined and undefining it and defining as 0 makes no difference.
EDIT: in fact I don't want to use millis() here at all. But it prevents me from using the timer overflow ISR. So if it is possible localy remove all the millis() functionality it would be even better (I planed to stop the other timer to get rid of unused millis() interrupts anyway).
Easiest way, don't use loop() and setup() but main(). But do note, this will also stop the setup of any of the Arduino functionality. So you have to setup things and/or include parts of the HAL you like. There is no normal way of disabling millis() from a sketch.
Thanks, it works. But what I have lost for this? What is the "HAL" and where I may find it?
EDIT: it works until I include DigiCDC.h which probably adds all the other files back
Interestingly (for me) defining the TIMER_TO_USE_FOR_MILLIS before including the library still not solves this.
HAL = Hardware Abstraction Layer
From wiki:
Hardware abstraction layer, a layer of software that hides hardware differences from higher level programs
So it's all the easy functions Arduino gives you to set peripherals without messing with the registers like digitalWrite(), digitalRead(), analogRead(), Serial etc.
Well I have found DigiCDC relies on millis(). If the timer is stopped it does not work.
Yeahh, a lot of it relies on millis() in the Arduino HAL and blocks that use the HAL. That's why it's not that easy to disable it...