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

 
 
> WinAvr бит установить?, Сбросить/установить бит.
UserM
сообщение May 7 2005, 20:56
Сообщение #1


Участник
*

Группа: Участник
Сообщений: 49
Регистрация: 26-02-05
Пользователь №: 2 909



Подскажите плз. Что делаю не правильно. Взял пример кода здесь:
http://www.ars.yet.ru/union/mk/mk06.html

Код
  int main(void)              
  {
   sbi (DDRD ,PD5);              
       while (1) {              
               cbi (PORTD,PD5);  
               delay_ms(500);  
               sbi (PORTD,PD5);  
               delay_ms(500);  
          }
  }

Но при компиляции возникает ошибка , что делаю не правильно?
Версия WinAVR - 20050214

Compiling: test.c
avr-gcc -c -mmcu=at90s4433 -I. -gstabs -DF_CPU=8000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=test.lst -std=gnu99 -MD -MP -MF .dep/test.o.d test.c -o test.o
test.c: In function `main':
test.c:31: warning: implicit declaration of function `sbi'
test.c:33: warning: implicit declaration of function `cbi'
test.c:38:5: warning: no newline at end of file

Linking: test.elf
avr-gcc -mmcu=at90s4433 -I. -gstabs -DF_CPU=8000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=test.o -std=gnu99 -MD -MP -MF .dep/test.elf.d test.o --output test.elf -Wl,-Map=test.map,--cref -lm
test.o(.text+0x2e): In function `main':
test.c:31: undefined reference to `sbi'
test.o(.text+0x38):test.c:33: undefined reference to `cbi'
test.o(.text+0x48):test.c:35: undefined reference to `sbi'
make: *** [test.elf] Error 1
Go to the top of the page
 
+Quote Post
 
Start new topic
Ответов
GedasL
сообщение May 8 2005, 07:48
Сообщение #2


Участник
*

Группа: Новичок
Сообщений: 18
Регистрация: 21-04-05
Пользователь №: 4 376



В WinAVR - 20050214 нет cbi и sbi О том что их небудет предупреждали уже давно.

#define bit_set(p,m) ((p) |= (m))
#define bit_clear(p,m) ((p) &= ~(m))
#define BIT(x) (0x01 << (x))

bit_set(PORTD,BIT(0));
bit_clear(PORTD, BIT(0));
Go to the top of the page
 
+Quote Post
UserM
сообщение May 8 2005, 18:40
Сообщение #3


Участник
*

Группа: Участник
Сообщений: 49
Регистрация: 26-02-05
Пользователь №: 2 909



GedasL, Спасибо, понял, всё работает.
Go to the top of the page
 
+Quote Post
ViktorK
сообщение May 9 2005, 10:28
Сообщение #4





Группа: Новичок
Сообщений: 4
Регистрация: 24-03-05
Пользователь №: 3 646



Цитата(UserM @ May 8 2005, 21:40)
GedasL, Спасибо, понял, всё работает.
*


Делай так:

Код
while (1) {           //Бесконечный цикл
       PORTB |= 1<<2;     //set PORTB.2 high
       delay_ms(500);     // Ждем 0.5 сек.
       PORTB &= ~(1<<2); //set PORTB.2 low
       delay_ms(500);     // Ждем 0.5 сек.
Go to the top of the page
 
+Quote Post



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

 


RSS Текстовая версия Сейчас: 21st July 2025 - 23:14
Рейтинг@Mail.ru


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