di ko alam...heheheilang time ba ang required para madaya ang mata sa mga multiplexed seven segment (in your case, tatlo yan)...? hehehe
50Hz minimum is enough for persistence of vision to work properly. That is why our power AC cycle frequency is 60Hz and europe uses 50Hz.So T = 1/50Hz = 20ms is required for 1 light to be seen as ON all the time.For 3 lights this will be 1/50/3 = 6.67 ms.
ano po pala ang pagkakaiba ng write_eeprom() sa write_program_eeprom()?
paano po yan sir, sobrang bilis pala... heheh e ang lowest possible TMRO overflow is 31.2ms? dapat pala po baguhin ang structure nung program. Di pupwede yung example ko?
The prescaler value for TMR0 should be lowered. TMR0 can be set to overflow minimum 256usec on 4MHz crystal.This is without prescaler. For the application a prescaler of 16 is advisable. T = Prescaler * 256 /(Fosc/4) = 16 * 256 / (4000000/4) = 4ms.This is chosen to be a bit lower than 6.67ms required to work.
Sir Zero, kung marami pa po palang processes kapag na reach ang 10mins in clarkent's application, dapat babaan pa, di ba? say prescaler of 8 na so that 2ms na ang overflow...
#define TMR0_SOFTWARE_DIVIDER (1000000UL/4096) void RTCC_isr(void) { static delay_counter = 0; ++delay_counter; if (delay_counter > TMR0_SOFTWARE_DIVIDER) { delay_counter = 0; RTCC_flag = TRUE; //fires when RTCC interrupt occurs } LED_matrix_scan_function();}
I once read that lot of process inside an ISR is not advisable, but now i realized it would still depend on a particular application.maraming-maraming salamat sir. pogi mo!
10 minutes is already very long in the MCU's point of view (600 million instructions) so irregardless of the number of tasks this still ok. The only thing needed is to modify the ISR function to not to set the flag too often by adding delay counters for this application to compensate for the faster TMR0 overflow interrupts.Like this:Code: [Select]#define TMR0_SOFTWARE_DIVIDER (1000000UL/4096) void RTCC_isr(void) { static delay_counter = 0; ++delay_counter; if (delay_counter > TMR0_SOFTWARE_DIVIDER) { delay_counter = 0; RTCC_flag = TRUE; //fires when RTCC interrupt occurs } LED_matrix_scan_function();}
#include <16F84A.h>#FUSES NOWDT,[color=red]LP[/color],NOPUT,NOPROTECT#use delay(clock=32768)#byte porta = 5#byte portb = 6 short RTCC_flag;int ones, tens, huns;#int_RTCCvoid RTCC_isr(void) { RTCC_flag = TRUE; //fires when RTCC interrupt occurs}void main(){ int sec, min; setup_timer_0(RTCC_INTERNAL|RTCC_DIV_128); //overflow every 1.0s enable_interrupts(INT_RTCC); enable_interrupts(GLOBAL); set_tris_a(0x00); set_tris_b(0x00); ones = 0x03; tens = 0x02; huns = 0x01; while(TRUE) { if(RTCC_flag) { RTCC_flag = FALSE; sec++; } if(sec>=15) { sec = 0; min++; } if(min>=10) { min = 0; disable_interrupts(GLOBAL); write_eeprom(ones,0x00); write_eeprom(tens,0x01); write_eeprom(huns,0x02); enable_interrupts(GLOBAL); } porta = ones; portb = 0x01; porta = tens; portb = 0x02; porta = huns; portb = 0x04; }}
#define TMR0_SOFTWARE_DIVIDER (1000000UL/4096)
#include <16F84A.h>#FUSES NOWDT,HS,NOPUT,NOPROTECT#define count_TIME 10 //in minutesshort RTCC_flag;int sec,min;#int_RTCCvoid RTCC_isr(void) { sec++; if (sec>=60) { sec=0; min++; if(min>=count_TIME) { min =0; RTCC_flag = TRUE; } } //... multiplexed seven segment rountine here.}void main(){ setup_timer_0(RTCC_INTERNAL|RTCC_DIV_16); //overflow every 4ms enable_interrupts(INT_RTCC); enable_interrupts(GLOBAL); while(TRUE) { if(RTCC_flag) { RTCC_flag = FALSE; //..... do the EEPROM THINGY HERE. } }}
Kent, i suggest to do the code this way....Code: [Select]#include <16F84A.h>#FUSES NOWDT,HS,NOPUT,NOPROTECT#define count_TIME 10 //in minutesshort RTCC_flag;int sec,min;#int_RTCCvoid RTCC_isr(void) { sec++; if (sec>=60) { sec=0; min++; if(min>=count_TIME) { min =0; RTCC_flag = TRUE; } } //... multiplexed seven segment rountine here.}void main(){ setup_timer_0(RTCC_INTERNAL|RTCC_DIV_16); //overflow every 4ms enable_interrupts(INT_RTCC); enable_interrupts(GLOBAL); while(TRUE) { if(RTCC_flag) { RTCC_flag = FALSE; //..... do the EEPROM THINGY HERE. } }}
short RTCC_flag;int msec4ms,sec,min; #int_RTCCvoid RTCC_isr(void) { msec4ms++; //increment every 4ms // 1 sec = 25*4ms if(msec>=25) { msec = 0; sec++; if (sec>=60) { sec=0; min++; if(min>=count_TIME) { min =0; RTCC_flag = TRUE; } } } //... multiplexed seven segment rountine here.}