Hi,
I get on well with the ECIO28P & ECIO40P but Hardware i2C, UART and SPI channels share some pins.
I know I could use the software (bit bang) version for some applications but where possible I've traditionally used the hardware output.
A) am I just making my life hard by trying to always use the Hardware channels for i2C and UART ? any reasons for/against software bit bang versions?
I think SPI must use the hardware channel.
B) If I do want to use several overlapping hardware channels; do I just need to initialise each type, just before calling the associated macro ?
Is there a down side to repeatedly toggeling between types and re-initiaising a comms interface at say 10Hz or greater?
UART > SPI > UART > SPI ... etc.
Thoughts and experiance appreciated! J.
i2C UART SPI Hardware Software Bitbang & Initialising
Moderator: Benj
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: i2C UART SPI Hardware Software Bitbang & Initialising
Hello,
SPI and I2C can both easily be bit banged with a software channel, the only downside is a potential loss of speed but there will be no data corruption. I2C is often pretty slow anyway and so there is no major downside to using software instead of hardware.
UART is more tricky as it's based heavily on timings and I would advise against using the software channel if possible.
If you can use individual pins and keep the busses enabled, if you have to multiplex then you can but you risk loss of incoming data or glitches on the data signals reaching the other slave devices and causing problems. If you have to do this then maybe use external resistors to pull up the signals to set default values when the MCU is not actively in charge of the pin. If you use the CAL versions of the components from the Creation menu then there should be an Uninitialise macro you can call to effectively switch off a peripheral.
SPI and I2C can both easily be bit banged with a software channel, the only downside is a potential loss of speed but there will be no data corruption. I2C is often pretty slow anyway and so there is no major downside to using software instead of hardware.
UART is more tricky as it's based heavily on timings and I would advise against using the software channel if possible.
If you can use individual pins and keep the busses enabled, if you have to multiplex then you can but you risk loss of incoming data or glitches on the data signals reaching the other slave devices and causing problems. If you have to do this then maybe use external resistors to pull up the signals to set default values when the MCU is not actively in charge of the pin. If you use the CAL versions of the components from the Creation menu then there should be an Uninitialise macro you can call to effectively switch off a peripheral.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel