CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

SPI and TMR0 interrupt?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
codewrecker2



Joined: 23 Dec 2005
Posts: 23

View user's profile Send private message

SPI and TMR0 interrupt?
PostPosted: Tue Aug 21, 2007 5:43 am     Reply with quote

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








PostPosted: Tue Aug 21, 2007 7:24 am     Reply with quote

Can you post the TMR0 interrupt?
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Tue Aug 21, 2007 8:04 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Aug 21, 2007 9:57 am     Reply with quote

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...
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group