cancel
Showing results for 
Search instead for 
Did you mean: 

Buffer Problems with ARM Compiler

Pje
Associate III

Hi All,

I need some help ,I am pulling my hair out ,

I declare a buffer of 40 Bytes 

 

uint8_t myBuffer[40]= {0};

 

I then read a nunber of bytes from an EEPROM over SPI ,I have a logic analyser connected and can see the for example if I read 10 buytes at address x the 10 bytes are in the correct order clocked out and the byte information is also as I have written then to these bytes ;

However the Byffer data always gets mixed up, bytes mssing and also in wrong array elements and some times on occasion they are correct. The read function that I am using has been tested and been used in many other projets with other compilers ,

I suspect it there is smeting in declaring and configuring the buffer in the RAM compler that I do not know about or not do ,Can you people please think and explain how to handle buffers(arrays ) in the ARM complilers.

Posting some code is a bit of a problem as it is a high security and special project ,I am affraid I will get huge problems .

a general hint and guide will help Please!!

Regards 

Pje

 

5 REPLIES 5

@Pje wrote:

the ARM complilers.


What "ARM compilers" - Keil? IAR? GCC?


@Pje wrote:

I suspect it there is smeting in declaring and configuring the buffer in the RAM compler that I do not know about or not do ,


Nope. What you've shown should be fine.

You need to show a minimum but complete example which illustrates the problem.

SofLit
ST Employee

Hello,


@Pje wrote:

Posting some code is a bit of a problem as it is a high security and special project ,I am affraid I will get huge problems .


As you can't post the code, the only thing we can do is to advice you to simplify your code as much as possible. Maybe try to create a very simple project to just read the EEPROM and fill the buffer. Do you get the same behavior?

+ you set the product TAG to STM32F1 are you sure? and isn't a Cortex M7 product. I mean data coherency issues  while using DMA!

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

>>Posting some code is a bit of a problem as it is a high security and special project

Then presumably you have more senior developers/coders who can help you directly? To debug your code and analyze the problem.

 

Probably got nothing to do with the buffer allocation. Look elsewhere. Does data get filled via IRQ or DMA? Does it need to be volatile?

Add instrumentation and output so you understand what's happening, as it happens. The code can be commented out for production, but you need to better understand the failure, and this is probably simpler than single stepping your own code.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Dear All ,

Thanks for the comments,

It is only a simple project with the SPI configuration an the EEPROM connected the Code reads the EEPROM(by SPI) the SPI  directly put the data bytes into the buffer , I have an logic analyser connected and I am writing the buffer out on the UART I can cearly see the buffer is mixed up, it is totaly out of sync with the MISO line shown by the LA ,

Any case I understand it difficult to judge by the little information ,I will try to show the the code in a way that does not violate my commitments.

It is Keil and STM Micro 32F103 

again thans for all the replies it is appreciated 

Pje

Ok, but mixed up how exactly? Bit / Byte shifted, reversed, consistent/inconsistent?

Check SPI configuration, sizes, phase, direction

Make sure to explictly clear auto/local variables/structures as these typically contain random stack junk.

Enable asserts() to do some more bounds/range scanning of parameters at the library level.

Check settings in the Peripheral registers vs those sent, expected or desired.

Make something that illustrates the issue minimally and doesn't violate top-secret expectations, I think this can be done without specific disclosure. But then you likely have staff who can assist you directly, or contractors with NDA's

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..