Discussion in "Project Help" started by    scorcho    Oct 19, 2006.
Thu Oct 19 2006, 09:02 am
#1
Hi,

I have a multi-file project and in main.c I have a global array to store a string of characters. In my main function I call function i2c_send from another file(i2c.c) that sends this string over i2c. Naturally, my i2c isr is in i2c.c, and naturally it needs to write the string into the i2c buffer for the transmission to begin. Since I can't pass the string into the isr as a parameter, the string within i2c has to be a global. Short of doing a strcpy in my i2c_send function, what can I do to let my isr refer to the string in main.c and copy that into the i2c buffer?
Thu Oct 19 2006, 11:30 pm
#2
simple make use of keyword "extern"
example:like you have a char variable in a file name file.c and u want to access it main.c

char a; //as defined in file.c

so in main.c you have to access it as

extern char a; //used in main.c

now for an array to access

char a[10]; //as defined in file.c

extern char a[10]; //used in main.c

i hope you understood.

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

ztaletpzca
Wed Apr 24 2024, 11:19 pm
IrardlPex
Wed Apr 24 2024, 08:42 pm
Charlestehed
Wed Apr 24 2024, 05:20 pm
Robertgurse
Wed Apr 24 2024, 02:43 pm
Richardedils
Wed Apr 24 2024, 04:07 am
Malcolmaccek
Wed Apr 24 2024, 01:21 am
ChrisLub
Tue Apr 23 2024, 05:21 pm
Davidbab
Tue Apr 23 2024, 10:41 am