Jump to content

Software Based I2c Driver


Recommended Posts

The i2c_driver (\SourceBoost\include\i2c_driver.h) that comes with the SourceBoost distibution provides a code template that has to be copied to the user's program. This template uses "unsigend short" data types where "unsigend char" should be sufficient.

 

Here are the wrong and the correct code:

 

wrong code:

// RAM used by the software i2c driver to emulate the equivalent i2c hardware registers

unsigned short swi2c_SSPCON1@0x40; // define location for the emulated SSPCON1

unsigned short swi2c_SSPCON2@0x41; // define location for the emulated SSPCON2

unsigned short swi2c_SSPSTAT@0x42; // define location for the emulated SSPSTAT

unsigned short swi2c_SSPBUF@0x44; // define location for the emulated SSPBUF

unsigned short swi2c_SSPIF_PIR@0x45; // define location for the emulated SSPIF_PIR

unsigned short swi2c_BCLIF_PIR@0x46; // define location for the emulated BCLIF_PIR

unsigned short swi2c_SSPADD@0x43; // define location for the emulated SSPADD

 

correct code:

// RAM used by the software i2c driver to emulate the equivalent i2c hardware registers

unsigned char swi2c_SSPCON1@0x40; // define location for the emulated SSPCON1

unsigned char swi2c_SSPCON2@0x41; // define location for the emulated SSPCON2

unsigned char swi2c_SSPSTAT@0x42; // define location for the emulated SSPSTAT

unsigned char swi2c_SSPBUF@0x44; // define location for the emulated SSPBUF

unsigned char swi2c_SSPIF_PIR@0x45; // define location for the emulated SSPIF_PIR

unsigned char swi2c_BCLIF_PIR@0x46; // define location for the emulated BCLIF_PIR

unsigned char swi2c_SSPADD@0x43; // define location for the emulated SSPADD

 

IDE version: 6.81

OS: WinXP

 

Comments:

This is a minor bug because the resulting code works.

 

BR

manuel123

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