lloydi12345
Member
Hi ETO, I would like to ask help about optimizing the speed of my software. The objective is to display characters on two dual 7segment temperature reading. The temperature reading happens every second. The problem is I could notice this flickering on display whenever the microcontroller does an ADC conversion from a thermistor.
Here's my software:
I tried changing my 4Mhz XT Oscillator to 8Mhz then 16Mhz it helped a bit though but didn't solve the problem. Also tried changing TMR1L to 0xFE for it to overflow quickly but still there is a flicker.
I could solve the problem by moving the code lines highlighted with "This segment to be placed in ISR" inside the ISR routine replacing the disp_flag that gets triggered when the interrupt occurs. I would like to optimize this since interrupt service routine should only contain flags to avoid future issues.
Thanks
Here's my software:
C:
void isr_high(void){
PIR1bits.TMR1IF =0; //clear Timer1 interrupt flag
isr_timer_segment++;
if(isr_timer_segment >8){
PIE1bits.TMR1IE =0;
INTCONbits.GIE =0;
isr_timer_segment =0;
disp_flag =1;
}
TMR1H =0xFF;
TMR1L =0x00;
}
.
.
.
void main(){
//Initializations of PORTS, modules, etc.
while(1){
[while(state ==0){
if(disp_flag ==1){
//////////////////////////////////////////////////This Segment
LATC = disp_holder;
LATD =0x00;
LATD = ds_data_holder[char_disp_num];
disp_holder = disp_holder <<1;
char_disp_num++;
if(char_disp_num >3){
char_disp_num =0;
disp_holder =0x10;
}
//////////////////////////////////////////////////to be placed in ISR
PIE1bits.TMR1IE =1;
INTCONbits.GIE =1;
disp_flag =0;
}
else{
get_temp_counter++;
if(get_temp_counter >5000){
get_temp_counter =0;
get_temperature();//get ADC reading, Average the reading to have a stable analog voltage reading
display_category = cat_temp;
choose_disp(display_category);
}
}
temp_holder = check_button();
}
}
}
I tried changing my 4Mhz XT Oscillator to 8Mhz then 16Mhz it helped a bit though but didn't solve the problem. Also tried changing TMR1L to 0xFE for it to overflow quickly but still there is a flicker.
I could solve the problem by moving the code lines highlighted with "This segment to be placed in ISR" inside the ISR routine replacing the disp_flag that gets triggered when the interrupt occurs. I would like to optimize this since interrupt service routine should only contain flags to avoid future issues.
Thanks
Last edited by a moderator: