I've built a PIC16F57 4 digit digital clock with 4 x 7 segment displays, with a strobe line activating each digit one at a time. I've got everything working nicely so that I have hours in one file register and minutes in another file register. I've also got a nice subroutine to add a minute to the time, and to display the contents of the time file registers.
In my main loop I then have
loop
call AddMinute ; adds minute to time file registers (carrying to hours as appropriate)
call MoveTimeToDisplay ; writes to 7 seg display with strobing
; some extra stuff
goto loop
My problem now, is how to invoke the AddMinute subroutine once every minute. Timer clock speed after prescaling is 2400Hz.
I had erroneously assumed I could use modification of code from Morton's 'The Pic Microcontroller - your personal introductory course' which uses 2 extra registers and code to divide 2400Hz to 1Hz, but I realise now, he's using the code to delay for 1 second, not to flag an action every second while going round the main loop. I realise in retrospect I should have used a pic with a timer that can raise an interrupt, but now I've invested time in hardware and software, I'd quite like to finish the project.
So in summary, is there a way I can trigger my subroutine exactly once every minute ?
Thanks,
Robin
In my main loop I then have
loop
call AddMinute ; adds minute to time file registers (carrying to hours as appropriate)
call MoveTimeToDisplay ; writes to 7 seg display with strobing
; some extra stuff
goto loop
My problem now, is how to invoke the AddMinute subroutine once every minute. Timer clock speed after prescaling is 2400Hz.
I had erroneously assumed I could use modification of code from Morton's 'The Pic Microcontroller - your personal introductory course' which uses 2 extra registers and code to divide 2400Hz to 1Hz, but I realise now, he's using the code to delay for 1 second, not to flag an action every second while going round the main loop. I realise in retrospect I should have used a pic with a timer that can raise an interrupt, but now I've invested time in hardware and software, I'd quite like to finish the project.
So in summary, is there a way I can trigger my subroutine exactly once every minute ?
Thanks,
Robin