CRC Evaluation using direct memory addressing

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

CRC Evaluation using direct memory addressing

84 Views
embedded_dan73
Contributor I

Hello all.

I'm working with S32K358 MCU, MBD Toolbox v1.6.0 and Matlab R2024a.

I know that Crc module isn't supported by the toolbox, so I configured the .mex file of the project in order to generate the RTD configuration suitable for my application, including Crc module, and then I wrote a Matlab function in order to manually call, as custom code, the "Crc_SetChannelCalculate" function.

This works fine and I can evaluate correctlty the CRC over a data streaming like an array.

Now what I would like to do is to evaluate the CRC on an area of memory, using directly the memory address as data input. If I write the code "manually" using S32DS IDE (outside Matlab), the code looks like this:

//--- code start

uint32 CrcResult;

uint8 *data;

data = (uint8 *)0x40A1F0; //arbitrary address chosen for starting calculation

CrcResult = Crc_SetChannelCalculate(CRC_LOGIC_CHANNEL_2, data, 16, 0, TRUE);

//in this way I calculate the CRC of 16 byte, with starting value = 0, read directly in flash starting from address 0x40A1F0

//---

Of course, before this, I initialized the logic channel CRC_LOGIC_CHANNEL_2 with the properties suitable for my application.

This code works fine but I'm not able to "translate" it on Matlab, because I didn't find a suitable way for make a direct memory addressing (and, if I'm not wrong, Matlab doesn't support this possibility).

I would please ask you if someone has an idea on how to face this matter.

Thansk in advance for your help and support.

 

Daniel

 

 

0 Kudos
Reply
0 Replies
%3CLINGO-SUB%20id%3D%22lingo-sub-2266820%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ECRC%20Evaluation%20using%20direct%20memory%20addressing%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2266820%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%20all.%3C%2FP%3E%3CP%3EI'm%20working%20with%20S32K358%20MCU%2C%20MBD%20Toolbox%20v1.6.0%20and%20Matlab%20R2024a.%3C%2FP%3E%3CP%3EI%20know%20that%20Crc%20module%20isn't%20supported%20by%20the%20toolbox%2C%20so%20I%20configured%20the%20.mex%20file%20of%20the%20project%20in%20order%20to%20generate%20the%20RTD%20configuration%20suitable%20for%20my%20application%2C%20including%20Crc%20module%2C%20and%20then%20I%20wrote%20a%20Matlab%20function%20in%20order%20to%20manually%20call%2C%20as%20custom%20code%2C%20the%20%22Crc_SetChannelCalculate%22%20function.%3C%2FP%3E%3CP%3EThis%20works%20fine%20and%20I%20can%20evaluate%20correctlty%20the%20CRC%20over%20a%20data%20streaming%20like%20an%20array.%3C%2FP%3E%3CP%3ENow%20what%20I%20would%20like%20to%20do%20is%20to%20evaluate%20the%20CRC%20on%20an%20area%20of%20memory%2C%20using%20directly%20the%20memory%20address%20as%20data%20input.%20If%20I%20write%20the%20code%20%22manually%22%20using%20S32DS%20IDE%20(outside%20Matlab)%2C%20the%20code%20looks%20like%20this%3A%3C%2FP%3E%3CP%3E%2F%2F---%20code%20start%3C%2FP%3E%3CP%3Euint32%20CrcResult%3B%3C%2FP%3E%3CP%3Euint8%20*data%3B%3C%2FP%3E%3CP%3Edata%20%3D%20(uint8%20*)0x40A1F0%3B%20%2F%2Farbitrary%20address%20chosen%20for%20starting%20calculation%3C%2FP%3E%3CP%3ECrcResult%20%3D%20Crc_SetChannelCalculate(CRC_LOGIC_CHANNEL_2%2C%20data%2C%2016%2C%200%2C%20TRUE)%3B%3C%2FP%3E%3CP%3E%2F%2Fin%20this%20way%20I%20calculate%20the%20CRC%20of%2016%20byte%2C%20with%20starting%20value%20%3D%200%2C%20read%20directly%20in%20flash%20starting%20from%20address%200x40A1F0%3C%2FP%3E%3CP%3E%2F%2F---%3C%2FP%3E%3CP%3EOf%20course%2C%20before%20this%2C%20I%20initialized%20the%20logic%20channel%20CRC_LOGIC_CHANNEL_2%20with%20the%20properties%20suitable%20for%20my%20application.%3C%2FP%3E%3CP%3EThis%20code%20works%20fine%20but%20I'm%20not%20able%20to%20%22translate%22%20it%20on%20Matlab%2C%20because%20I%20didn't%20find%20a%20suitable%20way%20for%20make%20a%20direct%20memory%20addressing%20(and%2C%20if%20I'm%20not%20wrong%2C%20Matlab%20doesn't%20support%20this%20possibility).%3C%2FP%3E%3CP%3EI%20would%20please%20ask%20you%20if%20someone%20has%20an%20idea%20on%20how%20to%20face%20this%20matter.%3C%2FP%3E%3CP%3EThansk%20in%20advance%20for%20your%20help%20and%20support.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EDaniel%3C%2FP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E