Using Boost-C I2C commands in Flowcode

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 2 and 3.

Moderators: Benj, Mods

Post Reply
Mark
Posts: 209
Joined: Thu Oct 19, 2006 11:46 am
Location: Bakewell, UK
Has thanked: 20 times
Been thanked: 16 times
Contact:

Using Boost-C I2C commands in Flowcode

Post by Mark »

Hi,

The I2C BoostC commands appear to be as follows :

void i2c_START(void) // Generates the I2C Bus Start Condition
void i2c_RESTART(void) // Generates the I2C Bus Restart Condition
void i2c_STOP(void) // Generates the I2C Bus Stop Condition
unsigned char i2c_WRITE(unsigned char i2c_data) // Generates the I2C Bus Write Condition
unsigned char i2c_READ(char ack_status) // Generates the I2C Bus Read Condition
void i2c_INIT(unsigned char i2c_divisor) // Generates the I2C Bus Initialization

these can presumably be used to generate a read and write along the lines of :

// Read from the External EEPROM
i2c_start();
i2c_write(HW_address); // send XEE i2c address
i2c_write(i2c_addr >> 8 ) ; // send XEE internal HIGH address
i2c_write((char) i2c_addr & 0x00ff); // send XEE internal LOW address
i2c_restart(); // send i2c_restart

// Write to the External EEPROM
i2c_start();
i2c_write(HW_address); // send XEE i2c address
i2c_write(i2c_addr >> 8 ) ; // send XEE internal HIGH address
i2c_write((char) i2c_addr & 0x00ff); // send XEE internal LOW address

However, after incorporating the command

#include <i2c_driver.h>

in the supplemantary code section of Flowcode I cannot get Flowcode to compile a C code icon containing any of these commands, e.g.

i2c_start();

in a C code icon is not recognised.

Please give me a starter in implementing the commands in Flowcode.

Thanks,

Mark
Go with the Flow.

User avatar
Steve
Matrix Staff
Posts: 3422
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Post by Steve »

Hello Mark,

If you look at the start of the "i2c_driver.h" file, it says the following:
////////////////////////////////////////////////////////////////////////////
// The following three sections should be copied to the user's program:
// i2c master hardware / software mode definition
// i2c software implementation template arguments and variables
// i2c hardwareware implementation template arguments
////////////////////////////////////////////////////////////////////////////
If you do add these to your "supplementary code" window before the #include statement, the code will compile.

However, the linker failed when I tried to compile this code at 19.6608MHz - I had to change the clock frequency to 20MHz.

Mark
Posts: 209
Joined: Thu Oct 19, 2006 11:46 am
Location: Bakewell, UK
Has thanked: 20 times
Been thanked: 16 times
Contact:

Post by Mark »

Steve,

Thanks, got the commands accepted.

Port C and Tris C definitions were objected to as redefined, so I simply deleted those entries.

Mark
Go with the Flow.

Post Reply