aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW/Embedded
diff options
context:
space:
mode:
authorVictoria Plitt <Victoria.Plitt@twine-s.com>2020-07-14 15:41:21 +0300
committerVictoria Plitt <Victoria.Plitt@twine-s.com>2020-07-14 15:41:21 +0300
commit42155b356d93de34d2d30cdc9e650bfcd9e6db68 (patch)
tree4f986b7b2f8b95ee5bcb40f2134fec98419e59af /Software/Embedded_SW/Embedded
parent9cafc2ab35e6ac87b3062b7be90a57645e4bd35b (diff)
parent38dc30f3a8fe7fe2cde7eb42cb72034e184bff07 (diff)
downloadTango-42155b356d93de34d2d30cdc9e650bfcd9e6db68.tar.gz
Tango-42155b356d93de34d2d30cdc9e650bfcd9e6db68.zip
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
Diffstat (limited to 'Software/Embedded_SW/Embedded')
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/I2C_Communication/I2C_Comm.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/I2C_Comm.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/I2C_Comm.c
index 99c865d87..9bcdec476 100644
--- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/I2C_Comm.c
+++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/I2C_Comm.c
@@ -54,7 +54,7 @@ uint32_t I2C_WriteBuff(uint32_t I2C_BASE, unsigned char addr, unsigned char* dat
if (len == 1)
{
I2CMasterControl(I2C_BASE, I2C_MASTER_CMD_SINGLE_SEND);
- SysCtlDelay(I2C_BUSY_DELAY);
+ SysCtlDelay(I2C_BUSY_DELAY);//The CPU waits for the Command processing to begin before it goes to check if the command is processed
while(I2CMasterBusy(I2C_BASE));
status |= I2CMasterErr(I2C_BASE);
}
@@ -62,7 +62,7 @@ uint32_t I2C_WriteBuff(uint32_t I2C_BASE, unsigned char addr, unsigned char* dat
{
// Start sending consecutive data
I2CMasterControl(I2C_BASE, I2C_MASTER_CMD_BURST_SEND_START);
- SysCtlDelay(I2C_BUSY_DELAY);
+ SysCtlDelay(I2C_BUSY_DELAY);//The CPU waits for the Command processing to begin before it goes to check if the command is processed
while(I2CMasterBusy(I2C_BASE));
status |= I2CMasterErr(I2C_BASE);
@@ -73,7 +73,7 @@ uint32_t I2C_WriteBuff(uint32_t I2C_BASE, unsigned char addr, unsigned char* dat
while(len > 1){
I2CMasterDataPut(I2C_BASE, *data);
I2CMasterControl(I2C_BASE, I2C_MASTER_CMD_BURST_SEND_CONT);
- SysCtlDelay(I2C_BUSY_DELAY);
+ SysCtlDelay(I2C_BUSY_DELAY);//The CPU waits for the Command processing to begin before it goes to check if the command is processed
while(I2CMasterBusy(I2C_BASE));
status |= I2CMasterErr(I2C_BASE);
@@ -84,7 +84,7 @@ uint32_t I2C_WriteBuff(uint32_t I2C_BASE, unsigned char addr, unsigned char* dat
// Send last piece of data
I2CMasterDataPut(I2C_BASE, *data);
I2CMasterControl(I2C_BASE, I2C_MASTER_CMD_BURST_SEND_FINISH);
- SysCtlDelay(I2C_BUSY_DELAY);
+ SysCtlDelay(I2C_BUSY_DELAY);//The CPU waits for the Command processing to begin before it goes to check if the command is processed
while(I2CMasterBusy(I2C_BASE));
status |= I2CMasterErr(I2C_BASE);
}
@@ -113,7 +113,12 @@ uint32_t I2C_ReadBuff(uint32_t I2C_BASE, unsigned char addr, unsigned char* data
if (len == 1)
{
I2CMasterControl(I2C_BASE, I2C_MASTER_CMD_SINGLE_RECEIVE);
- SysCtlDelay(I2C_BUSY_DELAY);
+ //On the TM4C129 we discovered a design behavior that due to higher system clock frequency and lower I2C baud rate,
+ //the CPU when it starts a I2C Transaction or writes a new I2C Command, for the I2C to respond to it takes time.
+ //So in effect the I2CMasterBusy statement gets skipped which causes The I2C controller to lose data.
+ //see: https://e2e.ti.com/support/microcontrollers/other/f/908/t/368493?Why-is-a-delay-needed-before-writing-the-first-byte-from-I2C-Master-
+ //therefore we need delay before waiting until bus is not busy - it doesn't work as expected without it or with while(!(I2CMasterBusy(I2C0_BASE)
+ SysCtlDelay(I2C_BUSY_DELAY);//The CPU waits for the Command processing to begin before it goes to check if the command is processed
while(I2CMasterBusy(I2C_BASE));
*data = I2CMasterDataGet(I2C_BASE);
status |= I2CMasterErr(I2C_BASE);
@@ -123,7 +128,7 @@ uint32_t I2C_ReadBuff(uint32_t I2C_BASE, unsigned char addr, unsigned char* data
// Start receiving consecutive data
I2CMasterControl(I2C_BASE, I2C_MASTER_CMD_BURST_RECEIVE_START);
- SysCtlDelay(I2C_BUSY_DELAY);
+ SysCtlDelay(I2C_BUSY_DELAY);//The CPU waits for the Command processing to begin before it goes to check if the command is processed
while(I2CMasterBusy(I2C_BASE));
*data = I2CMasterDataGet(I2C_BASE);
status |= I2CMasterErr(I2C_BASE);
@@ -135,7 +140,7 @@ uint32_t I2C_ReadBuff(uint32_t I2C_BASE, unsigned char addr, unsigned char* data
// Continue receiving consecutive data
while(len > 1){
I2CMasterControl(I2C_BASE, I2C_MASTER_CMD_BURST_RECEIVE_CONT);
- SysCtlDelay(I2C_BUSY_DELAY);
+ SysCtlDelay(I2C_BUSY_DELAY);//The CPU waits for the Command processing to begin before it goes to check if the command is processed
while(I2CMasterBusy(I2C_BASE));
*data = I2CMasterDataGet(I2C_BASE);
status |= I2CMasterErr(I2C_BASE);
@@ -146,7 +151,7 @@ uint32_t I2C_ReadBuff(uint32_t I2C_BASE, unsigned char addr, unsigned char* data
// Receive last piece of data
I2CMasterControl(I2C_BASE, I2C_MASTER_CMD_BURST_RECEIVE_FINISH);
- SysCtlDelay(I2C_BUSY_DELAY);
+ SysCtlDelay(I2C_BUSY_DELAY);//The CPU waits for the Command processing to begin before it goes to check if the command is processed
while(I2CMasterBusy(I2C_BASE));
*data = I2CMasterDataGet(I2C_BASE);
status |= I2CMasterErr(I2C_BASE);