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

interrupts on 16f628a

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



Joined: 04 May 2008
Posts: 260

View user's profile Send private message

interrupts on 16f628a
PostPosted: Mon Dec 07, 2009 5:54 pm     Reply with quote

Hi

I try use this PIC with interrupts.

On datasheet it have one external interrupt on pin RB3 and I like use it to connect a switch, but I like connect on other RB pins some leds.

Program work if I make some like this:

My problem stay on use interrupt on pin RB0 and call him to make my sequence.
Code:

int8 count = 0;

#int_ext
void int_rb0()
{
   count++:
}


void seq1()
{
Output_B(0b01000000);
Output_B(0b00100000);
Output_B(0b00010000);
Output_B(0b01000000);
Output_B(0b00100000);
Output_B(0b00010000);
}

void seq2()
{
Output_B(0b00000000);
Output_B(0b01000000);
Output_B(0b01100000);
Output_B(0b01110000);
Output_B(0b01111000);
Output_B(0b01110000);
Output_B(0b01100000);
Output_B(0b01000000);
}


void main()
{
   enable_interrupts(GLOBAL);
   enable_interrupts(INT_EXT);     
   setup_timer_2(T2_DIV_BY_1, 255, 1);
   setup_ccp1(CCP_PWM);
   set_pwm1_duty(0);  //0 até 255

while(1)
   {
if (count==0) seq1();
if (count==1) seq2();

if (count>=2) count=0;
   }
}

Best regards
filjoa



Joined: 04 May 2008
Posts: 260

View user's profile Send private message

PostPosted: Thu Dec 10, 2009 8:21 am     Reply with quote

Hi

Interrupts finally work fine but have a problem....

When I write this:
Code:

void seq1()
{
Output_B(0b00000001); delay_ms(200);
Output_B(0b00000100); delay_ms(200);
Output_B(0b00000010); delay_ms(200);
Output_B(0b00001000); delay_ms(200);
}


It don't work... I need write this way:
Code:

void seq1()
{
output_high(PIN_B7); output_low(PIN_B6);output_low(PIN_B5); output_low(PIN_B4); delay_ms(200);
output_low(PIN_B7); output_high(PIN_B6);output_low(PIN_B5); output_low(PIN_B4); delay_ms(200);
output_low(PIN_B7); output_low(PIN_B6);output_high(PIN_B5); output_low(PIN_B4); delay_ms(200);
output_low(PIN_B7); output_low(PIN_B6);output_low(PIN_B5); output_high(PIN_B4); delay_ms(200);
}


Someone can explain me why?

PS: It only occur on PIC16F628A because I try on PIC18F252 and this two ways work fine.

best regards
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