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

Michailqfh
Fri Mar 29 2024, 01:53 am
Bobbyerilar
Thu Mar 28 2024, 08:08 am
pb58
Thu Mar 28 2024, 05:54 am
Clarazkafup
Thu Mar 28 2024, 02:24 am
Walterkic
Thu Mar 28 2024, 01:19 am
Davidusawn
Wed Mar 27 2024, 08:30 pm
Richardsop
Tue Mar 26 2024, 10:33 pm
Stevencog
Tue Mar 26 2024, 04:26 pm