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 support@ccsinfo.com

trouble with the #INT_RB interruption and SPI interface

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



Joined: 28 Apr 2013
Posts: 3

View user's profile Send private message

trouble with the #INT_RB interruption and SPI interface
PostPosted: Sun Apr 28, 2013 4:52 pm     Reply with quote

hi all i have trouble with the #INT_RB interruption. I use PIC18F4550. I sent data from PIC to ADS1299 over the SPI interface but the INT_RB interruption is only executed at the last of program, not when B4 change level. If any one can explain me what to do??
thnx Rolling Eyes
dyeatman



Joined: 06 Sep 2003
Posts: 1924
Location: Norman, OK

View user's profile Send private message

PostPosted: Sun Apr 28, 2013 5:15 pm     Reply with quote

The folks here are not mind readers.

You have to provide a short program that demonstrates the problem.

Be sure to include all the setup and processor definition lines.
_________________
Google and Forum Search are some of your best tools!!!!
mrad13



Joined: 28 Apr 2013
Posts: 3

View user's profile Send private message

PostPosted: Sun Apr 28, 2013 5:53 pm     Reply with quote

Code:
#int_RB
void  RB_isr(void)
{
disable_interrupts(INT_RB);
output_low(CS);
SPI_WRITE(0xFF);
Delay_ms(20);
// val=SPI_READ(0);     
output_high(CS);
//printf("%s",val);               
}

void main()
{
setup_spi(SPI_MASTER|SPI_L_TO_H|SPI_CLK_DIV_4);   

while(true)
  {
   output_low(CS);
   SPI_WRITE(0x01);
   output_high(CS);

   output_low(CS);
   SPI_WRITE(0x02);
   output_high(CS);

   output_low(CS);
   SPI_WRITE(0x03);
   output_high(CS);

   output_low(CS);
   SPI_WRITE(0x04);
   output_high(CS);     
     
   setup_adc_ports(NO_ANALOGS|VSS_VDD);
   setup_adc(ADC_OFF);
   setup_psp(PSP_DISABLED);
   setup_spi(SPI_MASTER|SPI_L_TO_H|SPI_CLK_DIV_4);
   setup_wdt(WDT_OFF);
   setup_timer_0(RTCC_INTERNAL);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);
   enable_interrupts(INT_RB);
   enable_interrupts(GLOBAL);
  }
 
}

Ok this is my code it supposed to send the values 0x01 0x02 0x03 0x04 over the SPI interface and if there is an interruption on B4 the value 0xFF is sent on SPI. But when i simulate it with ISIS Proteus and when i provoke an interruption thanks to a button relied to B4 he continue sending all the values then he send the value 0XFF.
temtronic



Joined: 01 Jul 2010
Posts: 9170
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Apr 28, 2013 8:18 pm     Reply with quote

rule #1) please read sticky PIC101
..contains important information

rule #2) Proteus aka ISIS is BUSTED.
..no one here wants to waste their time recoding busted code

rule #3) you do not need to disable interrupts within it's own ISR
..the CCS C compiler does this for you !

rule #4) never put delays within any ISR
..ISRs are supposed to be fast, no thumb twiddling allowed

rule #5) you _must_ read portB to clear the interrupt status
..explained in the datasheet of the PIC(all are the same,in this aspect.

rule#6) you shouldn't use printf within the ISR
..again, ISRs are supposed to be fast,printf take 'forever'.

rule #7) ISRs _must_ be short and fast!
..get in,set a flag or two,update a variable, then get out, FAST

hth
jay
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