View previous topic :: View next topic |
Author |
Message |
codewrecker2
Joined: 23 Dec 2005 Posts: 23
|
SPI and TMR0 interrupt? |
Posted: Tue Aug 21, 2007 5:43 am |
|
|
Hi,I am using compiler PCM ver 3.237 for 16f689. I am using the spi port to talk to maxim 6950 7 seg led driver.My cause of grief is the TMR0 interrupts and spi_write() function when used together.
Piece of code:
Code: |
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
disable_interrupts(INT_RTCC); //it seems to interfere with spi
for(count=0;count<2;count++)
{
spi_write(buf[count]);
}
enable_interrupts(INT_RTCC); //re-enable ticks
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
}
|
If i remove the disable_int(tmr0) from the above code,the control seems to go to the tmr0 service routine infinitely(in mplab+real world).Why is this? am i supposed to disable the interrupts like this? i would loose my all so precious time counter ticks this way.
Anyways,When i disabled the tmr0 during spi write,all seemed to be working till i saw that NOW,INTF was getting set even though (RA2 pin) its a constant high.what am i supposed to do ,just clear it and assume ALL IS WELL?
Any help would be appreciated |
|
|
Guest
|
|
Posted: Tue Aug 21, 2007 7:24 am |
|
|
Can you post the TMR0 interrupt? |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Tue Aug 21, 2007 8:04 am |
|
|
Please don't start a new thread for the same topic. When you want to bump your question to the top of the list again you can post in the existing topic.
You get much better and faster replies when you post a short and complete program here. With complete I mean that it includes all #fuse settings,etc, so we can copy/paste the code into our compiler without modifications. Short == not more than what fits on a single page.
From your other thread I understand your timer 0 is generating an interrupt every 60us. That's very often considering the overhead of interrupts. To check for performance issues we need an answer to the following questions:
- What does your setup for the RTCC timer look like?
- What is your clock speed?
- What is the value defined for RTCC_init?
And just in case there is another problem, post your SPI initialization code as well.
Had you posted a complete program I didn't have to ask these questions. |
|
|
codewrecker2
Joined: 23 Dec 2005 Posts: 23
|
|
Posted: Tue Aug 21, 2007 9:57 am |
|
|
ckielstra wrote: |
Had you posted a complete program I didn't have to ask these questions. |
Certainly man,with all due respect.was just one of those days where nothing seemed to go my way.thought i wud start afresh.obviously Thinking was out of question.will post a close to complete code tomorow.
cheers... |
|
|
|