Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
LinkBack Thread Tools Display Modes
Old 18th December 2003, 11:49 AM   (permalink)
Default PICF452 I2C routine in microchip C

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
barfly is offline  
Old 18th December 2003, 11:59 AM   (permalink)
Default

You can find I2C related routines in this C file.
http://www.phanderson.com/PIC/PICC/C.../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.
__________________
"There is no way to peace, peace is the way!"
kinjalgp is offline  
Old 18th December 2003, 12:30 PM   (permalink)
Default

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();

}
barfly is offline  
Old 18th December 2003, 03:36 PM   (permalink)
Default

What problem are you facing?
__________________
"There is no way to peace, peace is the way!"
kinjalgp is offline  
Old 22nd December 2003, 09:19 AM   (permalink)
Default

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();
barfly is offline  
Reply

Bookmarks

Thread Tools
Display Modes





All times are GMT. The time now is 04:19 AM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

eXTReMe Tracker