реклама на сайте
подробности

 
 
> Xmega32E5 непонятка, проект на CVAVR
Фишер
сообщение Dec 8 2014, 13:35
Сообщение #1





Группа: Новичок
Сообщений: 4
Регистрация: 7-12-14
Пользователь №: 84 017



Здравствуйте всем.
Настроил 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 на входе порта.
Что-то я не так делаю?
Спасибо за ответ.
Go to the top of the page
 
+Quote Post



Reply to this topicStart new topic
1 чел. читают эту тему (гостей: 1, скрытых пользователей: 0)
Пользователей: 0

 


RSS Текстовая версия Сейчас: 27th June 2025 - 09:26
Рейтинг@Mail.ru


Страница сгенерированна за 0.01334 секунд с 7
ELECTRONIX ©2004-2016