View previous topic :: View next topic |
Author |
Message |
Grokiff
Joined: 25 Mar 2015 Posts: 2
|
INT_EXT on B0 |
Posted: Wed Mar 25, 2015 9:31 am |
|
|
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
|
|
Posted: Wed Mar 25, 2015 11:38 am |
|
|
I'd be looking at the hardware. Whisker between pins, inadequate decoupling, etc.. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Mar 25, 2015 9:45 pm |
|
|
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. |
|
|
|