|
|
View previous topic :: View next topic |
Author |
Message |
Guest
|
Software I2C master problem |
Posted: Thu May 03, 2007 7:40 am |
|
|
The device hangs up when I do not use the I2C hardware pins.
When I use PIN_B6 for SCL it works, and pin A4 is toggling, so do the I2C pins.
When I use PIN_B7 (or any other pin) for SCL there is no activity on pin A4 or the I2C pins.
Any ideas?
I need to use software I2C, I will later on use 2 I2C ports...
Code: | #include <16F690.h>
#device adc=8
#FUSES NOWDT //No Watch Dog Timer
#FUSES INTRC_IO //Internal RC Osc, no CLKOUT
#FUSES NOPROTECT //Code not protected from reading
#FUSES BROWNOUT //Reset when brownout detected
#FUSES MCLR //Master Clear pin enabled
#FUSES NOCPD //No EE protection
#FUSES NOPUT //No Power Up Timer
#FUSES NOIESO //Internal External Switch Over mode disabled
#FUSES NOFCMEN //Fail-safe clock monitor disabled
#use delay(clock=8000000)
#define SC_SDA PIN_B4
#define SC_SCL PIN_B6
#use i2c(Master, sda=SC_SDA, scl=SC_SCL, slow, STREAM=SC1 )
void main()
{
int16 x;
int8 y;
set_tris_a(4);
output_a(4);
while(TRUE) {
x = 12345;
y = 12;
i2c_start( SC1 );
i2c_write (SC1, make8(x,1));
i2c_write (SC1, make8(x,0));
i2c_write (SC1, y);
i2c_stop( SC1 );
output_low(PIN_A4);
delay_ms(50);
output_high(PIN_A4);
delay_us(10);
}
}
|
|
|
|
Guest
|
|
Posted: Thu May 03, 2007 7:45 am |
|
|
This works!
#define SCENECAM_SDA PIN_C6
#define SCENECAM_SCL PIN_B4
This makes the compiler hang!
#define SCENECAM_SDA PIN_B4
#define SCENECAM_SCL PIN_C6 |
|
|
Guest
|
|
Posted: Thu May 03, 2007 7:52 am |
|
|
C0 and C1 does not work together either! :( |
|
|
rnielsen
Joined: 23 Sep 2003 Posts: 852 Location: Utah
|
|
Posted: Thu May 03, 2007 9:00 am |
|
|
Quote: | #use i2c(Master, sda=SC_SDA, scl=SC_SCL, slow, STREAM=SC1 )
|
I2C statements do not use a 'Stream'. This is for defining multiple RS232 ports. Try taking that out of your #USE statement and see what happens.
Ronald |
|
|
strombom
Joined: 04 May 2007 Posts: 4
|
|
Posted: Fri May 04, 2007 12:57 am |
|
|
According to the manual it does:
STREAM=id
Associates a stream identifier with this I2C port. The identifier may then be used in functions like i2c_read or i2c_write.
I also got this answer from support before I bought the compiler:
Code: |
Do something like:
#use i2c(Master,Slow,sda=PIN_B4,scl=PIN_C6, STREAM=ONE)
#use i2c(Master,Slow,sda=PIN_C0,scl=PIN_A2, STREAM=TWO)
i2c_start( ONE );
|
|
|
|
rnielsen
Joined: 23 Sep 2003 Posts: 852 Location: Utah
|
|
Posted: Fri May 04, 2007 10:30 am |
|
|
Okay, I don't use Version 4 yet because of the bugs and Stream was not an option in V3.xxx.
Ronald |
|
|
|
|
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
|