Здравствуйте всем.
Настроил PORTD на вход с pull-up, инверсию не включал. Пины не подключены, на всех Uпит. Считываю состояние порта в переменную, вместо FF нули.
1. Настройка порта
char t;//
// PORTD initialization
// OUT register
PORTD.OUT=0x00;
// Pin0: Input
...
// Pin7: Input
PORTD.DIR=0x00;
// Pin0 Output/Pull configuration: Totempole/Pull-up (on input)
// Pin0 Input/Sense configuration: Sense both edges
// Pin0 Inverted: Off
PORTD.PIN0CTRL=PORT_OPC_PULLUP_gc | PORT_ISC_BOTHEDGES_gc;
// Pin1 Output/Pull configuration: Totempole/Pull-up (on input)
// Pin1 Input/Sense configuration: Sense both edges
// Pin1 Inverted: Off
PORTD.PIN1CTRL=PORT_OPC_PULLUP_gc | PORT_ISC_BOTHEDGES_gc;
// Pin2 Output/Pull configuration: Totempole/Pull-up (on input)
// Pin2 Input/Sense configuration: Sense both edges
// Pin2 Inverted: Off
PORTD.PIN2CTRL=PORT_OPC_PULLUP_gc | PORT_ISC_BOTHEDGES_gc;
// Pin3 Output/Pull configuration: Totempole/Pull-up (on input)
// Pin3 Input/Sense configuration: Sense both edges
// Pin3 Inverted: Off
PORTD.PIN3CTRL=PORT_OPC_PULLUP_gc | PORT_ISC_BOTHEDGES_gc;
// Pin4 Output/Pull configuration: Totempole/Pull-up (on input)
// Pin4 Input/Sense configuration: Sense both edges
// Pin4 Inverted: Off
PORTD.PIN4CTRL=PORT_OPC_PULLUP_gc | PORT_ISC_BOTHEDGES_gc;
// Pin5 Output/Pull configuration: Totempole/Pull-up (on input)
// Pin5 Input/Sense configuration: Sense both edges
// Pin5 Inverted: Off
PORTD.PIN5CTRL=PORT_OPC_PULLUP_gc | PORT_ISC_BOTHEDGES_gc;
// Pin6 Output/Pull configuration: Totempole/Pull-up (on input)
// Pin6 Input/Sense configuration: Sense both edges
// Pin6 Inverted: Off
PORTD.PIN6CTRL=PORT_OPC_PULLUP_gc | PORT_ISC_BOTHEDGES_gc;
// Pin7 Output/Pull configuration: Totempole/Pull-up (on input)
// Pin7 Input/Sense configuration: Sense both edges
// Pin7 Inverted: Off
PORTD.PIN7CTRL=PORT_OPC_PULLUP_gc | PORT_ISC_BOTHEDGES_gc;
// PORTD Peripheral Output Remapping
// USART0 XCK: Pin 1
// USART0 RXD: Pin 2
// USART0 TXD: Pin 3
PORTD.REMAP=(0<<PORT_USART0_bp) | (0<<PORT_TC4D_bp) | (0<<PORT_TC4C_bp) | (0<<PORT_TC4B_bp) | (0<<PORT_TC4A_bp);
// Interrupt level: Disabled
PORTD.INTCTRL=PORT_INTLVL_OFF_gc;
// Pin0 Pin Change interrupt : Off
...
// Pin7 Pin Change interrupt : Off
PORTD.INTMASK=0x00;
2. Кусок моей проги
t=PORTD.IN;//
if (t==0xFF) t=1;//
else t=0;//
Переменная t всегда равна 0, хотя должна быть 1 при FF на входе порта.
Что-то я не так делаю?
Спасибо за ответ.