- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please teach me how to transmit data to external 16 bit D/AC (AD5696, Analog Devices) by using I2C master in PSoC 5LP. I programmed C firmware refer to Sample Code "DelSig_I2CM" in PSoC creator, not only D/AC didn't work , but also SDA and SCL signal have been seen using oscilloscope.
-------------------------------------------------------------------------------------------
/* Parameters used:
* I2C Master
* Implementation Fixed function
* Data rate 400kbps
* SDA SCL pin config Open drain, drives low
* Pull-up resistors 1.8kΩ each
*
* Delta Sigma ADC
* Resolution 12 bits
* Conversion Rate 1000000 SPS
* Input mode Single ended
*/
#include <project.h>
#define I2C_SLAVE_ADDRESS (12u)
#define WR_BUFFER_SIZE (2u)
uint8 X_IN = 0u;
uint8 temp = 0u;
uint8 sample_segment[WR_BUFFER_SIZE];
uint16 result[3] = {0u};
int main(void)
{
ADC_SAR_IN_Start();
ADC_SAR_IN_StartConvert();
I2CM_Start();
CyGlobalIntEnable;
for(;;)
{
ADC_SAR_IN_IsEndConversion(ADC_SAR_IN_WAIT_FOR_RESULT);
result[X_IN] = ADC_SAR_IN_GetResult16();
sample_segment[0] = result[X_IN] >> 8u & 0x00FFu;
sample_segment[1] = result[X_IN] & 0x00FFu;
do
{
temp = I2CM_MasterWriteBuf(I2C_SLAVE_ADDRESS, (uint8 *)sample_segment, WR_BUFFER_SIZE, I2CM_MODE_COMPLETE_XFER);
}
while(temp != I2CM_MSTR_NO_ERROR);
while(I2CM_MasterStatus() & I2CM_MSTAT_XFER_INP);
temp = I2CM_MasterClearStatus();
}
}
Solved! Go to Solution.
- Labels:
-
PSoC 5LP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You have got two candidates for infinite loops in your program which can be overcome by a reset only.
while(temp != I2CM_MSTR_NO_ERROR);
while(I2CM_MasterStatus() & I2CM_MSTAT_XFER_INP);
I would consider a different solution in case of detected errors or timeouts.
It is much easier for us to help you, when you post your complete project, so that we all can have a look at all of your settings. To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You have got two candidates for infinite loops in your program which can be overcome by a reset only.
while(temp != I2CM_MSTR_NO_ERROR);
while(I2CM_MasterStatus() & I2CM_MSTAT_XFER_INP);
I would consider a different solution in case of detected errors or timeouts.
It is much easier for us to help you, when you post your complete project, so that we all can have a look at all of your settings. To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.
Bob