PICF452 I2C routine in microchip C

Status
Not open for further replies.

barfly

New Member
Hey,

does any of you have a C routine i can start with for displaying some characters on an I2C display (maxtrix orbital 2041)

Thanks,

K
 
You can find I2C related routines in this C file.
https://www.phanderson.com/PIC/PICC/CCS_PCM/24_256_1.html

You will require following routines from this file.
byte i2c_in_byte(void);
void i2c_out_byte(byte o_byte);
void i2c_nack(void);
void i2c_ack(void);
void i2c_start(void);
void i2c_stop(void);
void i2c_high_sda(void);
void i2c_low_sda(void);
void i2c_high_scl(void);
void i2c_low_scl(void);

Don't forget to change the I2C port pin definitions.

Now that you have all I2C routines, you just need to send command and data to your display driver using them.
 
Thank,

i have this file you mention.
Still, the microchip C-compiler has all the commands 'embedded'.
I want to start writing with the microchip C-compiler commands.

ex.

void main (void)
{

//i2c_start();
//i2c_out_byte(0xa0 | (dev_adr << 1));
//i2c_nack();
//i2c_out_byte((mem_adr >> 8) & 0xff); // high byte of memory address
//i2c_nack();
//i2c_out_byte(mem_adr & 0xff); // low byte of mem address
//i2c_nack();
//i2c_out_byte(dat); // and finally the data
//i2c_nack();
//i2c_stop();



OpenI2C(MASTER, SLEW_ON);
StartI2C();
WriteI2C(0xB8); //B8 = display adress
NotAckI2C();
WriteI2C(0xFE); // command prefix
NotAckI2C();
WriteI2C(0x46); // Turn backlight off
NotAckI2C();
StopI2C();
CloseI2C();

}
 
Well, why is this routine not doing what it should do.
address the display, and turn the backlight off.

OpenI2C(MASTER, SLEW_ON);
StartI2C();
WriteI2C(0xB8); //B8 = display adress
NotAckI2C();
WriteI2C(0xFE); // command prefix
NotAckI2C();
WriteI2C(0x46); // Turn backlight off
NotAckI2C();
StopI2C();
CloseI2C();
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…