View previous topic :: View next topic |
Author |
Message |
codewrecker2
Joined: 23 Dec 2005 Posts: 23
|
Function call disables interrupt?? |
Posted: Wed Aug 15, 2007 3:35 am |
|
|
Hello frnds,
I have a query(as well as a problem) regarding function calls in my pcm compiler ver 3.237
Every time i make a call to one function"display_write(..." my interrupts are being automatically disabled(or so i think) as i dont get ticks on my RTCC(timer0-timer mode).The reason i think this function is a problem is because if i comment it out all is OK.
The list file shows the following:
Code: |
....................
.................... Display_write(FALSE,0);
04CA: CLRF 6E
04CB: CLRF 6F
....................
.................... }
*
04EB: BCF 0A.3
04EC: GOTO 52F (RETURN)
|
Why aint ther a CALL/GOTO here after Diplay_write .As u can c below,52F is a location in main loop afte the function call
Code: |
.................... while(1) //Do continuously
.................... {
....................
.................... Debounce_switches();
052C: GOTO 482
.................... debounce_DIPS();
052D: GOTO 496
.................... Show_Dips_switches();
052E: GOTO 4BD
.................... // mycounter();
.................... if(Nozzle_IN_count==255)
052F: INCFSZ 50,W
|
The funtion itself is:
Code: |
//Function: Display Write
//Purpose: Buffers up the 5 global digits and displays
//needs: arg1(issame),if true implies same char for all digits
// common_char(arg2) is that SAME CHAR.
//Frequency: To be called as needed (any state)
void Display_write (short issame,int common_char)
{
int display_buffer[5],i;
if(issame)
{for(i=0;i<5;i++)
display_buffer[i]=common_char;
}
else
{display_buffer[0]=display_0; //digit0->left most digit->msd
display_buffer[1]=display_1; //digit1
display_buffer[2]=display_2; //digit2
display_buffer[3]=display_3; //digit3
display_buffer[4]=display_4; //digit4
}
display_led(display_buffer); //DISPLAY !!
}
void display_led(int* display_chars)
{
int char_count,temp,digit_address;
digit_address=digit_4; //first digit from left
for(char_count=0;char_count<5;char_count++)
{
temp=*display_chars;
my_spi_write(digit_address,temp);
digit_address--;
display_chars++;
}
}
void my_spi_write(int8 reg_address,int8 reg_value)
{
int8 count,buf[2];
buf[0]=reg_address;
buf[1]=reg_value;
output_low(led_maxCS_pin);
delay_cycles(4); // let cs go low
for(count=0;count<2;count++)
{
spi_write(buf[count]);
}
delay_cycles(4); // let lastbit be stable
output_high(led_maxCS_pin);
delay_cycles(4); //before we come back in here ,let CS be stable
}
|
Has anyone encountered a similar problem?or is it just me.Please help
Regds,
GSK
Last edited by codewrecker2 on Wed Aug 15, 2007 4:16 am; edited 1 time in total |
|
|
codewrecker2
Joined: 23 Dec 2005 Posts: 23
|
|
Posted: Wed Aug 15, 2007 4:14 am |
|
|
Also ,the following is the stack usage ,if u guys wanna know if m killing/overflowing the stack.
Code: |
CCS PCM C Compiler, Version 3.237, 26394 14-Aug-07 16:35
Filename: test_this.lst
ROM used: 1340 words (33%)
Largest free fragment is 2048
RAM used: 78 (31%) at main() level
148 (58%) worst case
Stack: 5 worst case (3 in main + 2 for interrupts)
|
& the isr is
Code: |
#INT_RTCC
void timer0_tick()
{static int pdINT_count;
set_timer0(RTCC_init); //see timers.h
pdINT_count++;
if (pdINT_count>85) //pedal sampled every 5msec(85x60us)
{pdINT_count=0; //reset count(global)
pedal_Debounce(); //The only CALL in isr
}
delay_count0++;
if(delay_count0==255)
{delay_count1++;
delay_count0=0;
}
if(delay_count1==255)
{delay_count2++;
delay_count1=0;
}
}
|
|
|
|
Ken Johnson
Joined: 23 Mar 2006 Posts: 197 Location: Lewisburg, WV
|
|
Posted: Wed Aug 15, 2007 6:38 am |
|
|
What is the code for pedalDebounce() ?
Ken |
|
|
codewrecker2
Joined: 23 Dec 2005 Posts: 23
|
|
Posted: Wed Aug 15, 2007 10:03 pm |
|
|
Here it is:
Code: |
#INLINE
void pedal_Debounce(void)
{
static int pedal_buffer;
rotate_left (&pedal,1); //Rotate pdin samples
if (!INPUT(pedal_PIN)) //Low is assumed a tentative press
{bit_clear(pedal_buffer,0); //
if (pd_IN_count <255) //Prevent overflow
pd_IN_count++; //when 255,pd pressed
}
else
{bit_set(pedal_buffer,0);
pd_IN_count=0; //pd back , so reset counter
}
} |
|
|
|
codewrecker2
Joined: 23 Dec 2005 Posts: 23
|
|
Posted: Thu Aug 16, 2007 3:03 am |
|
|
OK Now i know that the absence of CALL in the listing file was because it was inline.NOW BUT WHAT DISABLES THE INTERRUPT?? |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
Re: Function call disables interrupt?? |
Posted: Thu Aug 16, 2007 5:57 am |
|
|
codewrecker2 wrote: | The list file shows the following:
Code: |
....................
.................... Display_write(FALSE,0);
04CA: CLRF 6E
04CB: CLRF 6F
....................
.................... }
*
04EB: BCF 0A.3
04EC: GOTO 52F (RETURN)
|
| The compiler did some optimization and inlined the Display_write() function. Note the '*' symbol in the list file, this indicates a gap in the memory address sequence. Now look at Display_Write() and you will see these missing memory addresses.
A design hint: with delay_count0, ...1 and ...2 you are creating a 24bit counter. Why not use the inbuilt int32 datatype? That would be much easier to use and is tested (you are now missing a few counts on overflow).
I have no clue as to why your interrupt is disabled, are you sure this is what is happening?
Do you have other interrupts besides the timer0 as well?
Do you get a compiler warning like 'Interrupts disabled during call to prevent re-entrancy'? |
|
|
codewrecker2
Joined: 23 Dec 2005 Posts: 23
|
|
Posted: Sat Aug 18, 2007 12:25 pm |
|
|
Hi ckielstra,I have the uart isr too but it neva got me any problem.and no,i dont get a "interrupts disabled during call......" too as i have made sure isr functions are never called from anywhere else in main loop and vice-versa.any other stuff i gotta try?
Also,Thanx 4 d 32 bit var stuff.dat had just skipped my brain. |
|
|
|