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

EXT_INTERRUPT with serial comm. dont work?

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








EXT_INTERRUPT with serial comm. dont work?
PostPosted: Fri Mar 28, 2008 1:55 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.
Ttelmah
Guest







PostPosted: Fri Mar 28, 2008 3:14 am     Reply with quote

Start with the external interrupt. You have potential delays in here, of up to 10300uSec. Now, the 12F675, does not have a hardware UART, so serial comms _require_ that the incoming data line is polled at no more than 1/2 the bit time, if characters are not to be missed, and during character receipt, nothing else can occur, or the data will be corrupted. At 1200bps half a bit time, is just 0.4mSec, so your interrupt _will_ destroy the data.
Then, you are using software delays in the interrupt handler. Do a search here about this. Basically anything else using software delays, will disable interrupts while they are used.
Seriously, what you are trying to do, won't work with software timings, and without a UART.
Choices:
1) You might be able to do what you want, by seting the hardware timer in the interrupt, and using _this_ to provide the delays with another interrupt. At 1200bps, if both interrupt handlers are kept short, serial receipt should then work, and without software delays in the interrupt, the int_ext, won't then be disabled.
2) Better probably to use another chip, with a hardware UART, and do the pulse timings in the 'main', rather than in the interurpt, and use an interrupt to handle the serial.
As opposed to the 'sledgehammer to crack a nut' analogy, you are under 'tooled' for this job, with the 12675, and trying to use a 'cotton bud to crack a nut'. Low probability of success.....

Best Wishes
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