Skip to main content
Associate II
July 18, 2023
Solved

struct pointer in SPC563Mx

  • July 18, 2023
  • 1 reply
  • 1019 views

Dear experts,

I am encountering an issue while assigning a value to an element of a struct that I'm using a pointer to access. The code compiles successfully and programs on our SPC563Mx MCU board. However, when attempting to assign a value to a specific element, the code does not function as expected. I'm wondering if there are any limitations or restrictions that I might be overlooking. Here is a snippet of the code I'm working with:

typedef struct _s1

{

s2 registers; // another struct inside this struct

bool writeCmd;

bool readCmd;

}s1;


in main.c, I have:

s1* ps1;      // global

ps1->writeCmd = 1;

If there are no inherent limitations, I would greatly appreciate your assistance in identifying the problem.

I would appreciate any insights or guidance regarding this issue. Thank you!

This topic has been closed for replies.
Best answer by Mina

I found the problem! I've had an error with malloc() function, so I've had commented it and forgot to resolve that! so my pointer was pointing to nothing! 

 

1 reply

MinaAuthorBest answer
Associate II
July 18, 2023

I found the problem! I've had an error with malloc() function, so I've had commented it and forgot to resolve that! so my pointer was pointing to nothing!