(void)

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决
988 次查看
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

标签 (1)
0 项奖励
回复
1 解答
741 次查看
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 项奖励
回复
7 回复数
741 次查看
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 项奖励
回复
741 次查看
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 项奖励
回复
742 次查看
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 项奖励
回复
741 次查看
nikivendola
Contributor III

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

Thank you and greetings

0 项奖励
回复
741 次查看
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 项奖励
回复
741 次查看
nikivendola
Contributor III

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

0 项奖励
回复
741 次查看
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