1

KS0108 GLCD ドライバー用の新しいアルゴリズムと機能を備えた新しい特別なライブラリを作成しています。ATMega16 を使用しています。私のドット マトリックス GLCD の寸法は 128x64 です。

#define コードを使用して別のポート ピンを定義するにはどうすればよいですか?
例: #define GLCD_CTRL_RESTART PORTC.0

IDE: AVR Studio 5
言語: C
モジュール: 128x64 ドット マトリックス GLCD
ドライバー: KS0108
マイクロコントローラー: ATMega16

どのヘッダーを使用すればよいか説明してください。また、ATMEga16 用の完全で非常に単純なコードを記述します。

4

2 に答える 2

1

どうもありがとう、しかし私はこの答えをAVR Freaksで見つけまし

BV=ビット値。

If you want to change the state of bit 6 in a byte you can use _BV(6) which is is equivalent to 0x40. But a lot us prefer the completely STANDARD method and simply write (1<<6) for the same thing or more specifically (1<<<some_bit_name_in_position_6)

For example if I want to set bit 6 in PORTB I'd use:
Code:
PORTB |=  (1 << PB6);

though I guess I could use:
Code:
PORTB |= _BV(6);

or
Code:
PORTB |= _BV(PB6);

But, like I say, personally I'd steer clear of _BV() as it is non standard and non portable. After all it is simply:
Code:
#define _BV(n) (1 << n)

anyway.

Cliff
于 2012-01-23T11:37:44.340 に答える