(void)

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 
883件の閲覧回数
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 解決策
636件の閲覧回数
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 返答(返信)
636件の閲覧回数
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 件の賞賛
636件の閲覧回数
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 件の賞賛
637件の閲覧回数
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 件の賞賛
636件の閲覧回数
nikivendola
Contributor III

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

Thank you and greetings

0 件の賞賛
636件の閲覧回数
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 件の賞賛
636件の閲覧回数
nikivendola
Contributor III

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

0 件の賞賛
636件の閲覧回数
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