??? 01/03/12 13:23 Read: times |
#185287 - Leave as ASM Responding to: ???'s previous message |
I do not know why your I2C bit banging did not work in C - I have done that in C on multiple architectures and had it work just fine - but you may want to consider just leaving it in ASM code and interface that to the rest of your program that is in C.
Some C compilers have an option whereby you can compile a C module to an assembly listing file. This can be useful for helping to get the interface to an ASM routine setup correctly. You write the C framework for your intended ASM function and then compile to the listing. Take the resulting listing and wrap that around your ASM bit-bang I2C code and you end up with a module you can link to the rest of your program. Life is even easier with some other C compilers that have provisions for "inline assembler code". You can make the interface to the bit bang routine in C and keep it that way but plunk your ASM code down into the middle of the functions. If you use the inline technique your code is sometimes easier to maintain but there can be subtle issues on register usage of the compiler that you need to understand. Michael Karas |
Topic | Author | Date |
MLX90614 IR Thermometer | 01/01/70 00:00 | |
Leave as ASM | 01/01/70 00:00 | |
RE: "I need to do it in C" ?? | 01/01/70 00:00 | |
let me guess | 01/01/70 00:00 | |
Sensor gone | 01/01/70 00:00 | |
the main diffrence between SMB and I²C | 01/01/70 00:00 | |
SMBus is like I2C.... | 01/01/70 00:00 | |
a likely cause | 01/01/70 00:00 | |
Which PIC? | 01/01/70 00:00 |