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

INT_EXT on B0

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



Joined: 25 Mar 2015
Posts: 2

View user's profile Send private message

INT_EXT on B0
PostPosted: Wed Mar 25, 2015 9:31 am     Reply with quote

Hi,

I've got an interrupt on B0 H_TO_L as follow :
Code:


#define ETOR            PIN_B0

void init_etor_int()
{
      ext_int_edge(H_TO_L);
      enable_interrupts(INT_EXT);
}

#INT_EXT
void etor_int()
{
   unsigned int8 val_etor = !(input(ETOR));

   if (val_etor)
   {
      putc('!');
      it_inc++;
   }
   else
      putc('?');
}

void main()
{
   set_tris_b(0b11000011);
   enable_interrupts(GLOBAL);               
   init_etor_int();
   while(1)
   {
      dialog_i2c();
   }
}


In the dialog_i2c() function, I read and write on PORTB.3, PORTB.4 and PORTB.5 for i2c application.
For that, I use some kind of code like :
Code:

#define I2C_SCL   PIN_B4
#define I2C_SDA  PIN_B5
#byte TRISB         = getenv("SFR:TRISB")
#bit TB3       = TRISB.3
#bit TB4       = TRISB.4
#define I2C_TRISSDA1 TB4

void my_tris_data_in()
{
   I2C_TRISSDA1 = 1;
}

void my_tris_data_out()
{
   I2C_TRISSDA1 = 0;
}

void i2c_func_sample()
{
   my_tris_data_out();
   output_high(I2C_SCL);
   output_high(I2C_SDA1);
}


When I read or write on these 3 PINs, the INT_EXT triggers and write some '!' or '?' on the serial port.

How can I prevent this issue ?
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Wed Mar 25, 2015 11:38 am     Reply with quote

I'd be looking at the hardware. Whisker between pins, inadequate decoupling, etc..
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Mar 25, 2015 9:45 pm     Reply with quote

If that doesn't solve your problem and you want more help,
1. Post your PIC.
2. Post a schematic of your external circuits (especially everything on Port B).
3. Post your CCS compiler version. It's given at the top of the .LST file.

How to post an image on the CCS forum:
Go to this website: http://postimage.org/
Upload your image. Select family safe. Then click the first button for
"Hotlink to Forum" to get a link to the image.
Then go to the CCS forum and type Ctrl-V to paste the link into a post.

If postimage.org doesn't work in your country, then use Google to find
another free image hosting site for forums.
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