Jump to content

Incorrect I2c Setup For 18f In Picdem 2 Demo C Code


Recommended Posts

I think the SSP Mode Select bits are setup incorrectly in the McFarlam's Picdem 2 + demo code. These are bits 3-0 in SSPCON1.

 

  #ifdef _PIC16
sspcon = 00101000b;				 // 16F877 has the same register, it's just labelled differently.
 #else
sspcon1 = 00101001b;				// Enable the serial port and configures the SDA and SCL pins as the serial port pins
 #endif								// I2C Master mode, clock = FOSC/(4 * (SSPADD + 1)), clock polarity == 0.

 

According to the comments on the last line in the above code, the first 4 bits of sspcon1 should be 1000 and not 1001. Indeed, the temperature sensor demo works only with sspcon1 = 00101000b. (As per the PIC18FXX2 datasheet). This means the only difference between 16F and 18F452 here should be the labeling of the register. The same is true for the 18F4520, which is what I'm running.

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...