Jump to content

Recommended Posts

I am trying to get an 18F4550 set up for i2c operation and I (foolishly) thought it would be a snap since I have i2c running solid on a 16F877A. I though all I would have to do is set up the template parameters for the 4550 but it still hangs up in the first call to the i2c_init at the i2c_stop function.

 

I have revised the i2c #defines as follows:

 

// template defs -- worked for 16f877 changed to 18f4550

// CHANGES FROM 16F877

#define e_MSSP_PORT PORTB // was PORTC FOR 877

#define e_MSSP_TRIS TRISB // was TRISC FOR 877

#define e_SSPCON1 SSPCON1 // was SSPCON for 877

#define e_SSPCON2 SSPCON2 // same

#define e_SSPSTAT SSPSTAT // same

#define e_SSPADD SSPADD // same

#define e_SSPBUF SSPBUF // same

#define e_SSPIF_PIR PIR1 // same

#define e_BCLIF_PIR PIR2 // same

#define e_SSPIF_BIT SSPIF // same

#define e_BCLIF_BIT BCLIF // same

 

What might I have missed in making this transition?

 

Link to post
Share on other sites
hi ryeg..

Sorry didnt really get wat you mean. But if your pic is master and the slave device is not releasing the clock then the I2C in master will hangup.

 

Thanks for the comment -- it's got me thinking.

 

I am starting to suspect a hardware problem too. Have a 256K eeprom hooked up and need to check wiring. Chip was OK in 877 circuit.

 

The hangup happens in the i2c_stop routine;

......

volatile bit l_rcen@T_i2c_SSPCON2.i2c_RCEN, l_pen@T_i2c_SSPCON2.i2c_PEN, l_sen@T_i2c_SSPCON2.i2c_SEN;

volatile bit l_rsen@T_i2c_SSPCON2.i2c_RSEN, l_acken@T_i2c_SSPCON2.i2c_ACKEN;

 

l_bclif = 0; // initialise the collision flag for this command

l_sspif = 0;

 

if (T_MODE & i2c_HW)

{

// Hardware I2C implementation

while (l_acken || l_rcen || l_pen || l_rsen || l_sen || l_rw)

if (T_MODE & i2c_reset_wdt)

clear_wdt();

 

l_pen = 1; // initiate STOP condition on the I2C bus

 

while (l_acken || l_rcen || l_pen || l_rsen || l_sen || l_rw || !l_sspif) //Hangs up in this while loop

if (T_MODE & i2c_reset_wdt)

clear_wdt();

}

else...............

 

 

I have to take a look at the chip config setup too as I may have something wrong in that mess of stuff.

 

 

The old adage "little things mean a lot" takes on new meaning in this stuff...

 

Rye

Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...