Пользователи PICC18 от HI-TECH! Нашел я (как мне показалось) ошибку (не линкуется проект), написал в службу поддержки и вот просьба прокомментировать их ответ(+)
(«Телесистемы»: Конференция «Микроконтроллеры и их применение»)

миниатюрный аудио-видеорекордер mAVR

Отправлено Вопрос 25 июня 2003 г. 11:45

Мое письмо в службу поддержки на ломаном английском :-) :

///////////////// это мое письмо ////////////////////////////////
Hi!
I think compiler (linker) PICC-18 v8.20PL4 has a memory allocation error.
See attached example for processor 18F242.
I can't declare variable (union) :

typedef union __table6 {
unsigned char c[ 56];
} table6;
table6 t6;
in my program because linker shows :
"Can't find 0x101 words (0x101 withtotal) for psect bss in segment RAM (error)".
But there is enought RAM for allocation "table6 t6" !

But I can declare other variable (array) with the same size :
unsigned char dummy[ sizeof(table6)] ;

I think this is a memory allocation error.

////////// а вот мой вложенный *.c-файл с примером //////

/* Program for processor 18F242
When I declare variable (see line 59):

table6 t6;

compiler (linker) picc18.exe shows :
Can't find 0x101 words (0x101 withtotal) for psect bss in segment RAM (error).

But there are enought bytes RAM memory!!!!

When I declare variable with the same size (see line 63):
unsigned char dummy[ sizeof(table6)] ;
compiler (linker) works properly

I think this is a memory allocation error.
*/


#include "pic18.h" // вообще-то надо одинарные кавычки

#define MAX_BUFFER 125

typedef struct __buf_union {
unsigned char c[ MAX_BUFFER];
} buf_union;

typedef struct __table2 {
unsigned char t[ 8] ;
} table2 ;

typedef struct __table3 {
unsigned char t[ 2];
} table3;

typedef struct __table4 {
char c[32];
} table4 ;

typedef struct __table5 {
char c[32];
} table5;

typedef struct __table6 {
unsigned char c[ 56];
} table6;

volatile buf_union buffer;

table2 t2;
table3 t3;
table4 t4;
table5 t5;


// NB!
// I can't uncomment declaration "table6 t6"
table6 t6;

// but I can uncomment declaration "unsigned char dummy[ sizeof(table6)]"
// it has the same size !!!
// unsigned char dummy[ sizeof(table6)] ;


volatile unsigned int foo ;
void main( void)
{
foo = sizeof( table6) ;

INTCON = 0;
do {
} while( 1);
}
/////конец файла////////////////////////
В общем я не могу объявить структуру "table6 t6" - ругается что недостаточно памяти, но могу объявить массив точно такой же длины как и эта структура - и все в порядке в этом случае. Попробуйте у себя откомпилить мой файл - пока не закомментируете объявление "table6 t6" будет ругаться. Но можно раскомментировать "unsigned char dummy[ sizeof(table6)]" и все в порядке (хотя памяти занимает столько же).

И вот что мне ответили из службы поддержки :

//////// ответ от службы поддержки /////////////
This is a limitation in the way the compiler works. It is present to
drastically reduce code size. The bss psects are limited to one bank in
size (100h), although you may have as many of them as you like. Objects
that
are placed into the bss psect are uninitialised objects which are
multi-byte
in length. Note that you can still define single objects larger than
on bank in size; they are placed in a different psect. Char objects are
also placed elsewhere.

To get around this you can place variable definitions over multiple
files.
Since this only affects globally defined objects, this does not need to
alter the way the program is structured.
/////////////////////////////////////////

Выскажите, пожалуйста, Ваши мнения. По-моему, этот компилятор не поддерживает стандарт языка "C". Да и вообще он же должен сам разобраться во всем и поместить переменную в свободную память !!!
Может, так им и написать, что они не правы ?

Составить ответ  |||  Конференция  |||  Архив

Ответы



Перейти к списку ответов  |||  Конференция  |||  Архив  |||  Главная страница  |||  Содержание  |||  Без кадра

E-mail: info@telesys.ru