(void)

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
885 Views
nikivendola
Contributor III

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

Labels (1)
0 Kudos
1 Solution
638 Views
mjbcswitzerland
Specialist V

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

View solution in original post

0 Kudos
7 Replies
638 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

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

pastedImage_0.png

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!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
638 Views
nikivendola
Contributor III

Yes, this is ok, but do not understand the void put in the brackets. And 'an education that I never found. What does?

0 Kudos
639 Views
mjbcswitzerland
Specialist V

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

0 Kudos
638 Views
nikivendola
Contributor III

The (void) is used only in this case, or may have other uses?

Thank you and greetings

0 Kudos
638 Views
mjbcswitzerland
Specialist V

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

0 Kudos
638 Views
nikivendola
Contributor III

ok, you can also recommend a guide for learning the interrupt handling in freescale?

0 Kudos
638 Views
mjbcswitzerland
Specialist V

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