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

 
 
> Keil не видит extern SFR bit
IF_P
сообщение Jan 2 2009, 14:40
Сообщение #1


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

Группа: Участник
Сообщений: 136
Регистрация: 2-01-06
Пользователь №: 12 772



51-й проц. Keil 2 V2.36. Когда программа была в одном файле, все работало. Разнес программу в отдельные файлы и поставил описания extern. Со всеми переменными и битами разобрался, а вот одного п/п не видит. Может потому, что SFR бит? Помогите разобраться.
Прикрепленные файлы
Прикрепленный файл  Ttt.rar ( 16.35 килобайт ) Кол-во скачиваний: 30
 
Go to the top of the page
 
+Quote Post
 
Start new topic
Ответов
тау
сообщение Jan 2 2009, 17:10
Сообщение #2


.
******

Группа: Участник
Сообщений: 2 424
Регистрация: 25-12-08
Пользователь №: 42 757



Цитата(IF_P @ Jan 2 2009, 17:40) *
51-й проц. Keil 2 V2.36. Когда программа была в одном файле, все работало. Разнес программу в отдельные файлы и поставил описания extern. Со всеми переменными и битами разобрался, а вот одного п/п не видит. Может потому, что SFR бит? Помогите разобраться.


попробуйте "bdata". Смысл имхо в том что не все sbit без bdata могут быть extern

Bit-addressable Objects
Bit-addressable objects are objects that can be addressed as words or as bits.
Only data objects that occupy the bit-addressable area of the 8051 internal
memory fall into this category. The Cx51 compiler places variables declared
with the bdata memory type into this bit-addressable area. Furthermore,
variables declared with the bdata memory type must be global. You may declare
these variables as shown below:
Код
int bdata ibase; /* Bit-addressable int */
char bdata bary [4]; /* Bit-addressable array */

The variables ibase and bary are bit-addressable. Therefore, the individual
bits of these variables may be directly accessed and modified. Use the sbit
keyword to declare new variables that access the bits of variables declared using
bdata. For example:
Код
sbit mybit0 = ibase ^ 0; /* bit 0 of ibase */
sbit mybit15 = ibase ^ 15; /* bit 15 of ibase */
sbit Ary07 = bary[0] ^ 7; /* bit 7 of bary[0] */
sbit Ary37 = bary[3] ^ 7; /* bit 7 of bary[3] */

The above example represents declarations, not assignments to the bits of the
ibase and bary variables declared above. The expression following the carat
symbol (‘^’) in the example specifies the position of the bit to access with this
declaration. This expression must be a constant value. The range depends on
the type of the base variable included in the declaration. The range is 0 to 7 for
char and unsigned char, 0 to 15 for int, unsigned int, short, and unsigned
short, and 0 to 31 for long and unsigned long.
You may provide external variable declarations for the sbit type to access these
types in other modules. For example:
Код
extern bit mybit0; /* bit 0 of ibase */
extern bit mybit15; /* bit 15 of ibase */
extern bit Ary07; /* bit 7 of bary[0] */
extern bit Ary37; /* bit 7 of bary[3] */

Declarations involving the sbit type require that the base object be declared with
the memory type bdata.
The only exceptions are the variants for special
function bits.

Special function bits represent an independent declaration class that may not be
interchangeable with other bit declarations or bit fields.
The sbit data type declaration may be used to access individual bits of variables
declared with the bdata memory type specifier.
Go to the top of the page
 
+Quote Post
IF_P
сообщение Jan 2 2009, 20:31
Сообщение #3


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

Группа: Участник
Сообщений: 136
Регистрация: 2-01-06
Пользователь №: 12 772



Цитата(тау @ Jan 2 2009, 19:10) *
попробуйте "bdata". Смысл имхо в том что не все sbit без bdata могут быть extern

Bit-addressable Objects

Попробовал поменять:

sbit Enable_Display = 0x90; // CS для дешифратора LCD P1.0

на

char bdata P1=0x90;
sbit Enable_Display = P1^0; // CS для дешифратора LCD P1.0

Откомпилировалось без ошибок, но программа не работает-не выполняется инициализация LCD, где и задействован этот сигнал.

PS.
Посмотрел в DEBUG.

Enable_Display=0; - не сбрасывается в 0, так и стоит "1"

Сообщение отредактировал IF_P - Jan 2 2009, 20:36
Go to the top of the page
 
+Quote Post



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

 


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


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