c - Address 0 being overwritten by NULL pointer on HCS08 -


On my 8-bit Freescale HCS08 micro, whenever I call a library function that returns values ​​for pointers, and I really do not want them, I threw them in a tap, eg.

  UART_SendBlock ((Four *) TeXSTER, Stellen (TEXTST), Faucet);  

The last argument type is uint16_t * and returns the number of characters actually sent, a value that I do not care about.

However, I was having problems with my micro on port A, the function was called every time, and debugging told me about the argument that screwing things up. The configurations of Port A remain at the address of 0x0000 and 0x0001, where there are numbers on NULL (aka (zero *) 0 ). I thought that NULL was some kind of magic, where it would not really do anything, but it does not seem like that.

My operation really looks hacked:

  define #MNUL (Zero *) (& mynull) uint32_t mynull;  

Is there a better solution? I tried to define MNUL to the unused section of memory on my processor, but due to this it was immediately reset.

Unless the documentation for UART_SendBlock indicates that a tap pointer is OK to pass it, then You probably get undefined behavior you do - and in this case it seems that the function just writes the address that you pass it to, address 0 - which comes under "undefined behavior".

Call it with a parameter, there is no reason to be "smart" about it.

  uint16_t unused_16; Uthystendblock ((* Four *) TeXstr, Stellen (Txst), and unused 04);  

If you have constrained resources, then do a global unused_16 and reuse it at other places


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -