cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 5, 3 & 1 MCU

Anonymous
Not applicable

Hi all i am Chetan new to Psoc

   

I am working on my college project where i have to calculate crc of the data using the generator polynomial and then that crc is attached to data once again and crc of the data+crc calculated whose remainder should be 0

   

My generator polynomial is X^16+X^12+X^11+X^10+X^8+X^7+X^6+X^3+X^2+X^1+1

   

Presently i am using SPI master to transmit data serially to CRC component present in the library

   

my code;

   

#include <device.h>
uint16 crcval,crcval1;
uint8 arr[2]=0;
void main()
{
SPIM_1_Start();
CRC_1_Start();
arr[0]=0x9a;
SPIM_1_WriteByte(0x9a);
CyDelay(1);
crcval=CRC_1_ReadCRC();
//CyDelay(1);
LCD_Char_Start();
LCD_Char_Position(0,0);
LCD_Char_PrintInt16(crcval);

SPIM_2_Start();
CRC_2_Start();

arr[1]=HI8(crcval);
arr[2]=LO8(crcval);

SPIM_2_PutArray(arr,3);//the data 9a+fcs is fed into array and array into SPI 2
CyDelay(2);
crcval1=CRC_1_ReadCRC();
LCD_Char_Position(1,7);
LCD_Char_PrintInt16(crcval1);
LCD_Char_Position(1,0);
LCD_Char_PrintInt8(arr[0]);
LCD_Char_PrintInt8(arr[1]);
    LCD_Char_PrintInt8(arr[2]);
    for(;;)
    {
        /* Place your application code here. */
    }
}
 

   

The data is inconsistant as the (data+crc )'s crc is not 0 .

   

I have been on this problem since very long please help.

   

i am attaching the schematic

   

Thanks

0 Likes
Reply
1 Solution
Anonymous
Not applicable

Attached is a project, that is tested to work perfectly.

View solution in original post

0 Likes
Reply
3 Replies
Anonymous
Not applicable

Hi Chetan,

   

What you are trying to do is perfectly correct. I recreated your schematic and code and figured out that there is one small mistake in the code. 

   

The API SPIM_2_PutArray(arr,3); writes the orginial data + CRC in to CRC2 module. After this you need to read the output of CRC2 component. Hence it had to be "crcval1=CRC_2_ReadCRC();" instead of "crcval1=CRC_1_ReadCRC();". Your modified code should look like this,

   

 

   

   

        arr[2]=LO8(crcval);

   

SPIM_2_PutArray(arr,3);//the data 9a+fcs is fed into array and array into SPI 2 

   

CyDelay(2);

   

crcval1=CRC_2_ReadCRC();

   

LCD_Char_Position(1,7);

   

 

   

Also I would recommend you to upgrade to latest version of PSoC Creator.

   

   

 

   



0 Likes
Reply
Anonymous
Not applicable

 thank you sir but i have tried with this also and still it is not working, and is not updating can really be a problem?

0 Likes
Reply
Anonymous
Not applicable

Attached is a project, that is tested to work perfectly.

View solution in original post

0 Likes
Reply