Hello,
in a program that runs the ASL of a MK10 the following statement appears that I can not understand:
if (uart-> S1 & UART_S1_RDRF_MASK) {(void) uart-> D;}
I do not know what means the (void). I can explain?
Thank you
Solved! Go to Solution.
Hi
uart->D;
causes a read of the register D to take place. However, the compiler will often generate a warning because the read value is not being used.
(void) uart->D;
does the same but stops the compiler generating the warning.
Therefore the (void) cast is used to quieten the compiler.
Regards
Mark
Hello niki,
I think this is just read the D register , the aim is clear the RDRF Flag.
You can see this in the RM
you can confirm it through the your project .
Hope it helps
Have a great day,
Alice Yang
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Yes, this is ok, but do not understand the void put in the brackets. And 'an education that I never found. What does?
Hi
uart->D;
causes a read of the register D to take place. However, the compiler will often generate a warning because the read value is not being used.
(void) uart->D;
does the same but stops the compiler generating the warning.
Therefore the (void) cast is used to quieten the compiler.
Regards
Mark
The (void) is used only in this case, or may have other uses?
Thank you and greetings
Hi
The use of (void) is explained (in German) at
https://de.wikipedia.org/wiki/Void_%28Schl%C3%BCsselwort%29
with links to further details in the C-programming guides/books.
These are the best sources for such a topic.
Regards
Mark
ok, you can also recommend a guide for learning the interrupt handling in freescale?
Hi
The ARM web site gives details of the Cortex interrupt handling and this is the best source for core-related details: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0439b/CHDIHEAF.html
For Kinetis peripheral details (including interrupt and DMA operation) the Kinetis user manual should be used.
For most practical learning and efficient developments the uTasker project allows all the details to be simulated and studied (from NVIC through peripherals, interrupts and DMA to full project simulation without the normal guessing games): eg. http://www.utasker.com/kinetis/TWR-K60N512.html
Regards
Mark