On my 8-bit Freescale HCS08 micro, whenever I call a library function that returns values to pointers I pass it, and I don't really want them, I threw in a NULL, e.g.
UART_SendBlock((char *)txstr, strlen(txstr), NULL);
The type of the last argument is uint16_t *
and returns the number of characters actually sent, a value I don't care about.
However, I was having problems with port A on my micro being hosed every time that function was called, and debugging pointed me to that argument screwing things up. Port A's configuration registers live at addresses 0x0000 and 0x0001, which is where NULL
(aka (void *)0
) points. I thought NULL
was somehow magic where it wouldn't actually do anything, but it doesn't seem so.
My workaround feels really hack:
#define MNUL (void *)(&mynull)
uint32_t mynull;
Is there a better solution? I tried defining MNUL to an unused segment of memory on my processor, but that causes an immediate reset.