PSoC™ 5, 3 & 1 Forum Discussions
I'm trying to let one master board read one byte from a slave board and display the read result in master's LCD.The result doesn't correct. Unfortunately, I don't know how to correct it. Could you please give me some suggestions? I really appreciate any help from you. You can read the programs and some explanations below. The project is also attached.
In my project, one PSoC 5 board used as a master is supposed to read one byte from a slave PSoC 5 board. Slave board's address is set to 8 in both topdesign and program. I also use a LCD to display the value which is read by master.
The program of master is here:
int main()
{
uint8 temp1,temp2;
uint8 buffer = 0x00;
LCD_Char_Start();
LCD_Char_PrintString("Start I2C");
I2CM_Start();
CyDelay(200u);
LCD_Char_ClearDisplay();
LCD_Char_PrintString("Enable Intrp");
/* Enable global interrupts - required for I2C */
CyGlobalIntEnable;
CyDelay(200u/*ms*/);
LCD_Char_ClearDisplay();
LCD_Char_PrintString("Clr I2C status");
I2CM_MasterClearStatus(); /* Clear any previous status */
CyDelay(200u/*ms*/);
while(1){
LCD_Char_ClearDisplay(); LCD_Char_PrintString("Sending data");
do{
temp1=I2CM_MasterReadBuf(I2C_SLAVE_ADDRESS, (uint8 *)&buffer, MRD_BUFFER_SIZE, I2CM_MODE_COMPLETE_XFER);
}while(temp1!=I2CM_MSTR_NO_ERROR);
LCD_Char_ClearDisplay(); LCD_Char_PrintString("Waiting for completion"); CyDelay(200u/*ms*/);
while(I2CM_MasterStatus() == I2CM_MSTAT_XFER_INP);
if(I2CM_MasterStatus()!=I2CM_MSTAT_RD_CMPLT){
LCD_Char_ClearDisplay(); LCD_Char_PrintInt8(I2CM_MasterStatus());
//when I run the project, LCD shows return value of I2CM_MasterStatus() is A1. What does it mean?
CyDelay(200u/*ms*/);
}
temp2=I2CM_MasterClearStatus();
LCD_Char_ClearDisplay();
if(temp2==I2CM_MSTAT_ERR_XFER){
LCD_Char_PrintString("I2C Error");
}else{
LCD_Char_PrintInt8(buffer);
}
/* Delay introduced for ease of reading LCD */
CyDelay(800u/*ms*/);
LCD_Char_ClearDisplay();
LCD_Char_PrintString("I2C Loop");
CyDelay(800u/*ms*/);
}
} /* End main */
/* [] END OF FILE */
Here is the program of slave:
int main()
{
uint8 buffer=0x01;
I2CS_SlaveSetAddress(8);
I2CS_SlaveInitReadBuf((uint8 *)&buffer, RD_BUFFER_SIZE);
/*start I2C Slave operation*/
I2CS_Start();
/* Enable global interrupts - needed for I2C operation */
CyGlobalIntEnable;
while(1){
while( I2CS_SlaveGetReadBufSize()< 1 );
buffer++;
I2CS_SlaveClearReadStatus();
I2CS_SlaveClearReadBuf();
}
return 0;
} /* End of main */
From my understanding, if the project works well, master can read slave's buffer where 0x01 stores and the buffer in master will be changed to 0x01 from 0x00. So that I can see 01 in LCD. However, when I run the project, I2CM_MasterStatus() return A1 and the buffer in master is still 0X00.
It is interesting that why the return value of I2CM_MasterStatus() is A1. I guess A1 shows me I2C_MSTAT_RD_CMPLT, I2C_MSTAT_ERR_ADDR_NAK and I2C_MSTAT_ERR_XFER . But why there is something wrong with address.
I'm so confused. I really appreciate any suggestions and help from you. Thank you so much!
Show LessWe have done some tests internally.
Using block transfers, we can only get about 500,000 bytes per second over the USB, using libUSB in Linux. This works out to 250,000 samples per second for a 12 bit SAR.
Using isochronous transfers with libUSB, we can get 1,100,000 bytes per second over the USB using libUSB in Linux. (You have to google a lot to get the isochronous transfer examples for LibUSB.) This works out to about 550,000 samples per second from a 12 bit SAR.
Using build in SPI, we can get about 1,200,000 samples per second (without DMA) off of the device. We are using 18 mhz clock, which we just found out is a no-no for 16 bit transfers, according to the data sheet for high speed.
We are currently seeing about 1us between data packets on the SPI. We will be attempting DMA. The DMA wizard refuses to recognize the SPI device (I guess because it is UDB based), and so we stole from the SPIM example project.
I will update this post with the results soon.
Any suggestions?
Show LessI've run into a frustrating basic math problem in creator 3.0. I have a function that takes an array of 8-byte values in little-endian format and converts it to a uint64. Very straight forward, except the generated code doesn't actually work. I have tried this multiple ways (from the obvious solution to super long-hand). I verified that the array pointer is passed in, I can access the data in the array from within the function, but I cannot manipulate the data. I finally broke the whole problem down into as simple a solution as possible (hoping the compiler couldn't not understand what I intended). Here is the resulting code (and it doesn't work).
uint64 TYPE_CONVERT_Uint8Array_to_Uint64( uint8* input ) { // This assumes one sent the data in little-endian format uint32 temp_LO = 0; uint32 temp_HI = 0; uint64 temp; temp_HI |= (((uint32)input[7]) << 24); temp_HI |= (((uint32)input[6]) << 16); temp_HI |= (((uint32)input[5]) << 8); temp_HI |= (((uint32)input[4]) << 0); temp_LO |= (((uint32)input[3]) << 24); temp_LO |= (((uint32)input[2]) << 16); temp_LO |= (((uint32)input[1]) << 8); temp_LO |= (((uint32)input[0]) << 0); temp = (uint64)temp_HI; temp = temp << 32; temp |= temp_LO; return( temp ); }
After all this work, temp_HI and temp_LO have the correct values, but I cannot physically assign temp_HI to temp! How does an assignment like that not work? I always get back 0x00000000. So any point in continuing is moot.
Anyone have any suggestions?
Show LessHi everyone !
Thank you for the possibility to make question here!
My code is using the internal EEPROM.
I am trying to follow the recommendation of Psoc_3 Architecture_TRM regarding Lvia and lvid as reset sources.
What I am trying to do is set those reset sources as interrupt and not reset.
I have attached the .c file with both register needed to write to avoid reset.
I do not know what I am missing, but the writing to register "RESET_CR1" doesn't work.
Writing to RESET_CR3 does work.
Any help will be very appreciated.
Show LessHello,
I'm trying to transfer data acquired from a sequencing SAR ADC to a UART block using DMA.
I used the code provided by the DMA Wizard.
The trouble is, I always get the data from the first TD and never from the second one.
Normally I used the ADC_SAR_Seq_1_SAR_SAR_WRK0_PTR (assuming I only have 1 instance of the sequencing SAR ADC) address to get the ADC value. But in this case, it only provides one of the channels' value (I have 2 channels, by the way).
I tried messing around and I found out that the sequencing SAR ADC is a sort of macro that includes two DMA transfers. I found out the final structure that houses the values from the 2 channels (in my case, its called ADC_SAR_Seq_1_finalArray[2].
I tried to transfer the data directly from there to the UART's TX register, but I still get only the first channel's value.
Am I missing something here? Or is there another way to do it?
I'll put the project as an attachment.
I'm pretty new to PSoC Creator so any in-depth comments and (positive) criticism is very welcomed.
Thanks.
How can i make boolean operation without logic gate in component catalog? i want to use only sorce code, but getting error while using "bool". it said "bool undefined identifier"
Show Lesswhenever i connect 10uH inductor to power supply ... it will effect my filter output. it create the noise . its boost up the power but effecting filter result .. how to resolve this ..
Show LessI have a project that is bootloadable and I want to make the application type normal again for debugging.
However, I select Build Settings and then Code generation and there is no Application Type selection available?
It used to be there but now seems to have vanished? Or maybe it moved (who moved my cheese).
It seems to be a problem only with creator 3.2, if I open the backup version and run in 3.1 it is ok.
Show LessI am a bit confused ovcer use of the EEPROM in the 5LP
Online examples state the entire rows must be read form eeprom, altered and written back. Hoewever, the datasheet for EEPROM in the schematic state you can read and write to any single byte using EEPEOM_ReadByte and EEPEOM_WriteByte.
Would someone please privide an example how I would write and read single bytes to EEPEOM.
Thanks
Show Less