Timed interrupts on 18M2

cpedw

Senior Member
I want to achieve Interrupt-like behaviour at fixed 5-50mS intervals (not accurately). I think this may be achieved using Timer1 but I can't find any description of this having been done previously. I think it should be possible to load a value in Timer1 then watch for overflow using a separate task. I appreciate that the overflow won't generate an interrupt directly but the 2nd task should spot it soon enough, I'm hoping.

I have tried (and failed so far) to understand use of peek/pokesfr to do that but so far only in the Simulator. Does peeksfr work in the simulator?

The objective is to reduce the brightness of an OLED by rapid on/off switching of the display. I have already used "254,19" to switch off the internal power of the OLED but it's still too bright for a bedroom clock, I've been told.

Another possible approach would be to use a spare PWM from a connected 14M2 to generate real interrupts on an input pin. Would that be simpler?

Derek
 

hippy

Technical Support
Staff member
I recall monitoring the timer on an M2 has been discussed in a number of threads and that should be possible. PEEKSFR and POKESFR do not work in the simulator.

You could generate real interrupts from a PWM. PWM won't go down to 20Hz but you can run faster and count interrupts down to get the desired rate. You should be able to use the PWM on the 18M2 to save using a second PICAXE.

Turning the display on and off is likely to generate some flicker or strobing however. Member nick12ab does have a blog entry describing how to add brightness control to Winstar OLED's at -

http://www.picaxeforum.co.uk/entry.php?49-Winstar-OLED-Brightness-Control
 

cpedw

Senior Member
I get the impression from nick's 2nd blog on the topic, http://www.picaxeforum.co.uk/entry.php?1629 that the dimmest achieved by his brightness control is the same as the command 254,19 achieves. Can anyone confirm this? I will experiment but I find it's difficult to quantify brightness when the different levels are not side by side.

Derek
 
Top