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

 
 
> Работает ли Atmega8 команда jmp?
ivstech
сообщение Nov 18 2006, 20:58
Сообщение #1


Местный
***

Группа: Свой
Сообщений: 204
Регистрация: 5-01-06
Пользователь №: 12 860



Вопрос возник в связи с тем, что по ошибке я в программе написал jmp вместо rjmp. Заметил вот только сейчас, когда разбирался, почему программа сбоит (перестает принимать данные (?) по UART).
Читаю Changes from Rev.
2486K-08/03 to Rev.
2486L-10/03
...
3. Removed instructions CALL and JMP from the datasheet. << убрали просто за ненадобностью или начиная с ревизии K она не работает?
У меня серия процессора 0536I. Команду JMP он отрабатывает
Go to the top of the page
 
+Quote Post
 
Start new topic
Ответов
Laksus
сообщение Nov 21 2006, 19:11
Сообщение #2


Частый гость
**

Группа: Участник
Сообщений: 146
Регистрация: 16-05-05
Пользователь №: 5 069



=GM=
Цитата
Не совсем так. "Функциональность" НЕ "покрывается полностью командой rjmp", поскольку команда относительного перехода работает в пределах +-2Кслова, но в атмеге8 имеется 4Кслова памяти, так что для перехода, скажем, из конца памяти в ее начало потребуется два rjmp, а не один.

Запускаем AVRStudio (4.12.498, у старых тоже должно быть),
отрываем Help-AVR Studio User Guide-Поиск.
Ищем слово wrap.
Находим Assembly project.
Читаем раздел:
Цитата
Wrap relative jumps
The AVR RJMP/RCALL instructions allow a 12-bit PC-relative offset, corresponding to +/-2k words. For devices with 4k words (8k bytes) or less FLASH program memory, the Wrap option causes the assembler's offset calculation to wrap around over the addressable program memory range, enabling the entire program memory to be addressed using these instructions.

For devices with more than 4k words of program memory, using this option may cause unpredictable results and it should be turned off.
If it is left on, the assembler will produce a warning when wrap takes effect:

warning: Wrap rjmp/rcall illegal for device > 4k words - Turn off wrap option and use jmp/call

This diagnostic is given as a warning and not an error to retain compatibility with earlier versions of the assembler, but should be treated as an error by the user. The JMP/CALL 2-word instructions take 22-bit absolute addresses and should be used instead.


То есть, для мега8 ставим галочку в настройках ассемблера:
Project-Assembler Options-Wrap Relative Jumps
и гуляем с помощью rjmp, или rcall по всей флэши.
А если у нас мега16 и выше, то эту галочку надо объязательно убрать.
____________________
Александр
2006 11 21
PS. Вот тут аналогичная тема обсуждалась:
http://www.fulcrum.ru/cgi-bin/bbs/mess_sel...4966&page=1
Go to the top of the page
 
+Quote Post
=GM=
сообщение Nov 21 2006, 20:09
Сообщение #3


Ambidexter
*****

Группа: Свой
Сообщений: 1 589
Регистрация: 22-06-06
Из: Oxford, UK
Пользователь №: 18 282



Цитата(Laksus @ Nov 21 2006, 16:11) *
Цитата

Wrap relative jumps
The AVR RJMP/RCALL instructions allow a 12-bit PC-relative offset, corresponding to +/-2k words. For devices with 4k words (8k bytes) or less FLASH program memory, the Wrap option causes the assembler's offset calculation to wrap around over the addressable program memory range, enabling the entire program memory to be addressed using these instructions.

For devices with more than 4k words of program memory, using this option may cause unpredictable results and it should be turned off. If it is left on, the assembler will produce a warning when wrap takes effect:

warning: Wrap rjmp/rcall illegal for device > 4k words - Turn off wrap option and use jmp/call

This diagnostic is given as a warning and not an error to retain compatibility with earlier versions of the assembler, but should be treated as an error by the user. The JMP/CALL 2-word instructions take 22-bit absolute addresses and should be used instead.


То есть, для мега8 ставим галочку в настройках ассемблера: Project-Assembler Options-Wrap Relative Jumps и гуляем с помощью rjmp, или rcall по всей флэши. А если у нас мега16 и выше, то эту галочку надо обязательно убрать

Не знал я, что авр-студия позволяет представлять смещение как беззнаковое (фактически это так), и не учитывать переполнения 12-битного счетчика команд. Теперь буду знать, спасибо, Александр.


--------------------
Делай сразу хорошо, плохо само получится
Go to the top of the page
 
+Quote Post



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

 


RSS Текстовая версия Сейчас: 22nd July 2025 - 03:06
Рейтинг@Mail.ru


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