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

serial comm with ext interrupt dont work?

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



Joined: 17 Jun 2005
Posts: 1

View user's profile Send private message

serial comm with ext interrupt dont work?
PostPosted: Fri Mar 28, 2008 1:56 am     Reply with quote

Hi everyone.
I'm working for RF remote dimmer project. But doesnt work true. Problem is: later a few receiving serial data, disabled ext interrupt?
i want to set in ext_int routine with that i received serial time data.

Code is below:

Receiver:

Code:

#include <12f675.h>

#FUSES intrc_io,NOMCLR,nowdt
#use delay(clock=4000000)
#use rs232(baud=1200,rcv=PIN_A5)

signed int16 gecikme;

#define triac   PIN_A4
#define led     PIN_A0

#BIT INTF=0x0B.1
#BIT INTEDG=0x81.6

//*****************************************************************************
#int_Ext
void isr()
{
 
  if (gecikme>=0 && gecikme<=10000) 
  {
   output_low(triac);
   delay_us (gecikme);
   output_high(triac);
   delay_us(300); 
   output_low(triac);
  }
 
  INTEDG=!INTEDG;
  INTF=0;
  //clear_interrupt(INT_EXT);
}
//******************************************************************************
 //         #byte OSCCAL = 0x90   
 //         #rom 0x3ff = {0x3470}


void main()
{   

// if i disable interrupts no problem serial comm.

enable_interrupts(GLOBAL);
enable_interrupts(int_ext); 
 
   for(;;)
   {
                 
         if(kbhit())
         {
          disable_interrupts(global);    // if any data in, disable interrupt
         
           
           if(getc()=='A' && getc()=='C') { gecikme=100;  enable_interrupts(global); }
           if(getc()=='K' && getc()=='P') { gecikme=9900; enable_interrupts(global); } 
         }
           
          enable_interrupts(global);      // if there isnt serial data, enable interrupt     
     
    }
}



Transmitter:

Code:

#include <12F675.h>
#fuses intrc_IO,NOWDT,nomclr,put  //dikkat
#use delay (clock=4000000)
#use rs232(baud=1200,xmit=PIN_A2)


#define BUTON1  PIN_A1
#define BUTON2  PIN_A0

void main()

     {   
      do
      {
     
       if(!input(BUTON2))
        {     output_high(pin_a1);
              printf("AC");
               delay_ms(150);
             
         }
         
        if(!input(BUTON1))
        {      output_low(pin_a1);
               printf("KP");
               delay_ms(150);
        }
     }while(true);
  }





if i disable interrupts, serial comm. working true but if enable, sometimes, ext int disabled. And serial comm doest work true?

Why doesent work my code? Help...

Thanks.
Matro
Guest







PostPosted: Fri Mar 28, 2008 2:31 am     Reply with quote

These 2 lines
Code:

if(getc()=='A' && getc()=='C') { gecikme=100;  enable_interrupts(global); }
if(getc()=='K' && getc()=='P') { gecikme=9900; enable_interrupts(global); }

are "dangerous" because once a getc() has been performed, the next one will wait till a new character is received.
So to enable interrupt again there is only a few solutions (x is any character) :
'A', 'C'
x, x, 'K', 'P'
x, x, x, x

ONLY these character series will re-enable the int_ext.
Is that the behavior you want?

Matro.
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