I'm going to write software SPI and I2C for PIC 8 bit MCU where I need to write command and read sensor data. I want to know what is the best practice to write such library.
As we can use delay statement for clock high and low state but its not a good practice (sounds to me) because delay statement blocks the execution and I belive it should be interrupt deriven for example I can use TMR0 to manage SCL/SCK state high/sow and on each Timer interrupt I can send and receive data.
I would appriciate if someone could help me on this, what sould be taken care while I'm writing this code for a low power project. If possible give me a small example just to understand the idea.
As we can use delay statement for clock high and low state but its not a good practice (sounds to me) because delay statement blocks the execution and I belive it should be interrupt deriven for example I can use TMR0 to manage SCL/SCK state high/sow and on each Timer interrupt I can send and receive data.
I would appriciate if someone could help me on this, what sould be taken care while I'm writing this code for a low power project. If possible give me a small example just to understand the idea.