energia / Energia

Fork of Arduino for the Texas Instruments LaunchPad's
http://energia.nu
Other
794 stars 672 forks source link

Delays in the Wire library #611

Closed elluna closed 9 years ago

elluna commented 9 years ago

I'm using Energia 0101E0014 with a Tiva-C Launchpad and using the Wire library to connect to some peripherals. My code worked initially with Arduino Mega and then I ported it to the Launchpad. I realized that the access to the peripherals was much slower than with Arduino. Having a look to the Wire.cpp source code I found that the functions getRxData() and sendTxData() include a delay(1), that means that every time they're called, a millisecond delay is introduced. I simply commented out those delays and now works fine. What are these delays for? Should I create a new bug fix to remove such delays?

Regards, Eduardo

rei-vilo commented 9 years ago

I guess those delays are required.

Have you tried I²C in fast mode (400 kHz) and fast mode+ (1 MHz)?

elluna commented 9 years ago

Hello, Required for what? I've just removed those delays and it is working perfectly with 4 devices connected. The speed problem is not related with the transmission speed, it is because the Tx and Rx functions waits for 1 ms before doing its job and I don't understand what this delay is for, because in all my testing is not required.

robertinant commented 9 years ago

The delays are indeed there get the correct behavior. With that said, it is not the right way to do it. Instead of delay, it should check if the master is busy. I have replaced the delays with while(ROM_I2CMasterBusy(MASTER_BASE));