board m52233demo problem with pins

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

board m52233demo problem with pins

ソリューションへジャンプ
1,505件の閲覧回数
jonasb
Contributor I

Hey how can I change that some pins are output and some pins are input

 

I want TIN0, TIN1, TIN2, TIN3 and IRQ7 set as input.

 

and I want AN0, AN1, AN2, AN3, AN4, AN5, AN6 and AN7 set as output.

 

and how do I assigned a name for these pins by example TIN0 ==> switch 1.

ラベル(1)
0 件の賞賛
返信
1 解決策
744件の閲覧回数
mjbcswitzerland
Specialist V

Hi

 

Most pins default to GPIO input with pull up resistor (around 25k). This means that TIN0..TIN3 don't need to be further configured to be used as input - simply read value from the SETTC register.

 

The IRQ inputs are an exception since they default to IRQ and not GPIO. To set to GPIO clear the bits 0xc000 in PNQPAR. This is then an input and can be read as bit 0x80 in the SETNQ register.

 

To set the AN port to all outputs write 0xff to the data direction register DDRAN. Then control their values by writing to the PORTAN register. [Alternatively to sets bit use SETAN, with a '1' at the bit(s) to be set, alternatively to clear bits use CLRAN, with '0' at the bits(s) to be cleared].

 

To read from TIN0 with the name SWITCH1 use a define

#define SWITCH1 0x01

then 

switch_state = ((SWITCH1 & SETTC) != 0); // 1 when '1' and 0 when '0'

 

Please read chapter 14 of the M52235 user's manual for full details about using GPIOs.

 

Regards

 

Mark

 

www.uTasker.com

- OS, TCP/IP stack, USB, device drivers and simulator for M521X, M521XX, M5221X, M5222X, M5223X, M5225X. One package does them all - "Embedding it better..."

 

元の投稿で解決策を見る

0 件の賞賛
返信
1 返信
745件の閲覧回数
mjbcswitzerland
Specialist V

Hi

 

Most pins default to GPIO input with pull up resistor (around 25k). This means that TIN0..TIN3 don't need to be further configured to be used as input - simply read value from the SETTC register.

 

The IRQ inputs are an exception since they default to IRQ and not GPIO. To set to GPIO clear the bits 0xc000 in PNQPAR. This is then an input and can be read as bit 0x80 in the SETNQ register.

 

To set the AN port to all outputs write 0xff to the data direction register DDRAN. Then control their values by writing to the PORTAN register. [Alternatively to sets bit use SETAN, with a '1' at the bit(s) to be set, alternatively to clear bits use CLRAN, with '0' at the bits(s) to be cleared].

 

To read from TIN0 with the name SWITCH1 use a define

#define SWITCH1 0x01

then 

switch_state = ((SWITCH1 & SETTC) != 0); // 1 when '1' and 0 when '0'

 

Please read chapter 14 of the M52235 user's manual for full details about using GPIOs.

 

Regards

 

Mark

 

www.uTasker.com

- OS, TCP/IP stack, USB, device drivers and simulator for M521X, M521XX, M5221X, M5222X, M5223X, M5225X. One package does them all - "Embedding it better..."

 

0 件の賞賛
返信