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

 
 
> Некорректно считывается TCNT1, ATmega168
OlegALL
сообщение Jan 16 2014, 11:50
Сообщение #1


Участник
*

Группа: Участник
Сообщений: 70
Регистрация: 30-11-10
Пользователь №: 61 275



Привет.
Проблема: неправильно считывается значение счётного регистра (TCNT1, ATmega168)

описание и код здесь: http://caxapa.ru/480467.html

помогите, горит проект! заранее спасибо
Go to the top of the page
 
+Quote Post
 
Start new topic
Ответов
HNK0
сообщение Jan 17 2014, 14:15
Сообщение #2





Группа: Участник
Сообщений: 13
Регистрация: 23-07-09
Пользователь №: 51 509



To do a 16-bit write, the high byte must be written before the low byte.
For a 16-bit read, the low byte must be read before the high byte.
Go to the top of the page
 
+Quote Post
ILYAUL
сообщение Jan 17 2014, 14:33
Сообщение #3


Профессионал
*****

Группа: Свой
Сообщений: 1 940
Регистрация: 16-12-07
Из: Москва
Пользователь №: 33 339



Цитата(HNK0 @ Jan 17 2014, 18:15) *
To do a 16-bit write, the high byte must be written before the low byte.
For a 16-bit read, the low byte must be read before the high byte.

И в чём подвох?


--------------------
Закон Мерфи:

Чем тщательнее составлен проект, тем больше неразбериха, если что-то пошло не так
Go to the top of the page
 
+Quote Post
HNK0
сообщение Jan 17 2014, 18:27
Сообщение #4





Группа: Участник
Сообщений: 13
Регистрация: 23-07-09
Пользователь №: 51 509



Цитата(ILYAUL @ Jan 17 2014, 11:33) *
И в чём подвох?


It is important to notice that accessing 16-bit registers are atomic operations. If an interrupt
occurs between the two instructions accessing the 16-bit register, and the interrupt code
updates the temporary register by accessing the same or any other of the 16-bit Timer Registers,
then the result of the access outside the interrupt will be corrupted. Therefore, when both
the main code and the interrupt code update the temporary register, the main code must disable
the interrupts during the 16-bit access.
Go to the top of the page
 
+Quote Post



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

 


RSS Текстовая версия Сейчас: 24th August 2025 - 03:52
Рейтинг@Mail.ru


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