Salvar na Flash + CW10 + display 2x16

Software e Hardware para uC da Qualcomm, NXP, FreeScale e Motorola

Moderadores: 51, guest2003

Re: Salvar na Flash + CW10 + display 2x16

Mensagempor cfreund » 17 Set 2018 20:33

egipts escreveu:Como faço para que o compilador calcule o espaço entre as variáveis sozinho?
const unsigned char txtL02[] @0x8011 = " INCENDIO L02 ";
const unsigned char txtL03[] @0x8022 = " INCENDIO L03 ";
const unsigned char txtL04[] @0x8033 = " INCENDIO L04 ";
const unsigned char txtL05[] @0x8044 = " INCENDIO L05 ";


Geralmente não é necessário apontar o endereço de memória. Declarando como const é o suficiente para o compilador trabalhar com o vetor na ROM.

Se não der certo, uma alternativa seria vetor bidimensional.
Cláudio F
Avatar do usuário
cfreund
Word
 
Mensagens: 672
Registrado em: 14 Out 2006 14:02
Localização: São Paulo

a

Mensagempor cfreund » 17 Set 2018 20:37

egipts escreveu:
cfreund escreveu:Outra forma é utilizando enum, coloque um variável do tamanho da struct.


Não entendi direito, mas vou pesquisar estes comandos...
Muito obrigado!


"enum" não, union.
Cláudio F
Avatar do usuário
cfreund
Word
 
Mensagens: 672
Registrado em: 14 Out 2006 14:02
Localização: São Paulo

Re: Salvar na Flash + CW10 + display 2x16

Mensagempor egipts » 17 Set 2018 20:57

cfreund escreveu:
egipts escreveu:Como faço para que o compilador calcule o espaço entre as variáveis sozinho?
const unsigned char txtL02[] @0x8011 = " INCENDIO L02 ";
const unsigned char txtL03[] @0x8022 = " INCENDIO L03 ";
const unsigned char txtL04[] @0x8033 = " INCENDIO L04 ";
const unsigned char txtL05[] @0x8044 = " INCENDIO L05 ";


Geralmente não é necessário apontar o endereço de memória. Declarando como const é o suficiente para o compilador trabalhar com o vetor na ROM.

Se não der certo, uma alternativa seria vetor bidimensional.


É que depois vou atualizar estes dados na flash... Aí pretendia fazer uma rotina que atualize todos e não um por um...
Mas vou testar...
Obrigado.
egipts
Byte
 
Mensagens: 318
Registrado em: 22 Out 2006 01:43
Localização: Mairiporã - SP

Re: Salvar na Flash + CW10 + display 2x16

Mensagempor Red Neck Guy » 17 Set 2018 21:37

Esse teu cliente fica em Balneário Camboriú?
ASM51 descanse em paz!
Avatar do usuário
Red Neck Guy
Dword
 
Mensagens: 1968
Registrado em: 12 Out 2006 22:24

Re: Salvar na Flash + CW10 + display 2x16

Mensagempor cfreund » 17 Set 2018 21:40

egipts escreveu:É que depois vou atualizar estes dados na flash... Aí pretendia fazer uma rotina que atualize todos e não um por um...
Mas vou testar...
Obrigado.


Código: Selecionar todos
const unsigned char txtL0x[][17] @ 0x8000 = {
    "  INCENDIO L01  ",
    "  INCENDIO L02  ",
    "  INCENDIO L03  ",
    "  INCENDIO L04  ",
    "  INCENDIO L05  ",
};
Cláudio F
Avatar do usuário
cfreund
Word
 
Mensagens: 672
Registrado em: 14 Out 2006 14:02
Localização: São Paulo

Re: Salvar na Flash + CW10 + display 2x16

Mensagempor egipts » 18 Set 2018 00:35

Aquino escreveu:Esse teu cliente fica em Balneário Camboriú?


Não fica não, mas aceito projetos de todas localidades e planetas... Principalmente se for em assembly... rs

www.egipts.com.br
Grato
egipts
Byte
 
Mensagens: 318
Registrado em: 22 Out 2006 01:43
Localização: Mairiporã - SP

Re: Salvar na Flash + CW10 + display 2x16

Mensagempor egipts » 18 Set 2018 00:44

Código: Selecionar todos
const unsigned char txtL0x[][17] @ 0x8000 = {
    "  INCENDIO L01  ",
    "  INCENDIO L02  ",
    "  INCENDIO L03  ",
    "  INCENDIO L04  ",
    "  INCENDIO L05  ",
};
[/quote]

Void LCD_write_string (const unsigned char *c){...}

E pra chamar L03 seria:
LCD_write_string (txtL0x[3]);

Correto?
Grato.
egipts
Byte
 
Mensagens: 318
Registrado em: 22 Out 2006 01:43
Localização: Mairiporã - SP

Re: Salvar na Flash + CW10 + display 2x16

Mensagempor cfreund » 18 Set 2018 00:57

Na verdade seria: "LCD_write_string (txtL0x[2])" , mas é isso aí!
Cláudio F
Avatar do usuário
cfreund
Word
 
Mensagens: 672
Registrado em: 14 Out 2006 14:02
Localização: São Paulo

Re: Salvar na Flash + CW10 + display 2x16

Mensagempor egipts » 18 Set 2018 22:06

cfreund escreveu:
egipts escreveu:É que depois vou atualizar estes dados na flash... Aí pretendia fazer uma rotina que atualize todos e não um por um...
Mas vou testar...
Obrigado.


Código: Selecionar todos
const unsigned char txtL0x[][17] @ 0x8000 = {
    "  INCENDIO L01  ",
    "  INCENDIO L02  ",
    "  INCENDIO L03  ",
    "  INCENDIO L04  ",
    "  INCENDIO L05  ",
};


Eu testei o "const" sem informar o endereço, mas ele joga na área anterior ao programa. Como coloquei o programa para iniciar em 0x8400 (Project.prm) ele colocou as variáveis nesta área protegida... Como indico que aquele grupo deverá ficar fora da "ROM" e "ROM1"? Tenho que criar uma outra ROM com READ_WRITE não tenho? Tipo ROM2 ou devo usar algo assim: ROM_VAR = READ_WRITE 0x8000 TO 0x83FF; ?

Project.prm:

/* This is a linker parameter file for the mc9s08pa32 */

NAMES END /* CodeWarrior will pass all the needed files to the linker by command line. But here you may add your own files too. */

SEGMENTS /* Here all RAM/ROM areas of the device are listed. Used in PLACEMENT below. */
Z_RAM = READ_WRITE 0x0040 TO 0x00FF FILL 0x9D;
RAM = READ_WRITE 0x0100 TO 0x103F FILL 0x9D;
ROM = READ_ONLY 0x8400 TO 0xFF6F FILL 0x9D;
ROM1 = READ_ONLY 0xFF80 TO 0xFFAF FILL 0x9D;
EEPROM = READ_ONLY 0x3100 TO 0x31FF FILL 0x9D;
/* INTVECTS = READ_ONLY 0xFFB0 TO 0xFFFF; Reserved for Interrupt Vectors */
END

PLACEMENT /* Here all predefined and user segments are placed into the SEGMENTS defined above. */
DEFAULT_RAM, /* non-zero page variables */
INTO RAM;

_PRESTART, /* startup code */
STARTUP, /* startup data structures */
ROM_VAR, /* constant variables */
STRINGS, /* string literals */
VIRTUAL_TABLE_SEGMENT, /* C++ virtual table segment */
DEFAULT_ROM,
COPY /* copy down information: how to initialize variables */
INTO ROM; /* ,ROM1: To use "ROM1" as well, pass the option -OnB=b to the compiler */

_DATA_ZEROPAGE, /* zero page variables */
MY_ZEROPAGE INTO Z_RAM;
END

STACKSIZE 0x80

VECTOR 0 _Startup /* Reset vector: this is the default entry point for an application. */
egipts
Byte
 
Mensagens: 318
Registrado em: 22 Out 2006 01:43
Localização: Mairiporã - SP

Re: Salvar na Flash + CW10 + display 2x16

Mensagempor egipts » 18 Set 2018 22:24

Acrescentei o ROM_VAR = READ_WRITE 0x8000 TO 0x83FF; no Project.prm e funcionou maios_ou_menos... a variável Conf_Boot foi para o 0x8000 e as txtLxx foram a partir do 0x8467...

Declarei assim:
const unsigned char txtL01[] = " INCENDIO L01 "; // @0x8000 ARRAY COM 17 BYTES
const unsigned char txtL02[] = " INCENDIO L02 "; // @0x8011
const unsigned char txtL03[] = " INCENDIO L03 "; // @0x8022
const unsigned char txtL04[] = " INCENDIO L04 "; // @0x8033
const unsigned char txtL05[] = " INCENDIO L05 "; // @0x8044
const unsigned char txtL06[] = " INCENDIO L06 "; // @0x8055
const unsigned char txtL07[] = " INCENDIO L07 "; // @0x8066
const unsigned char txtL08[] = " INCENDIO L08 "; // @0x8077
const unsigned char txtL09[] = " INCENDIO L09 "; // @0x8088
const unsigned char txtL10[] = " INCENDIO L10 "; // @0x8099
const unsigned char txtL11[] = " INCENDIO L11 "; // @0x80AA
const unsigned char txtL12[] = " INCENDIO L12 "; // @0x80BB
const unsigned char txtL13[] = " INCENDIO L13 "; // @0x80CC
const unsigned char txtL14[] = " INCENDIO L14 "; // @0x80DD
const unsigned char txtL15[] = " INCENDIO L15 "; // @0x80EE
const unsigned char txtL16[] = " INCENDIO L16 "; // @0x80FF
const unsigned char txtL17[] = " INCENDIO L17 "; // @0x8110
const unsigned char txtL18[] = " INCENDIO L18 "; // @0x8121
const unsigned char txtL19[] = " INCENDIO L19 "; // @0x8132
const unsigned char txtL20[] = " INCENDIO L20 "; // @0x8143
const unsigned char txtL21[] = " INCENDIO L21 "; // @0x8154
const unsigned char txtL22[] = " INCENDIO L22 "; // @0x8165
const unsigned char txtL23[] = " INCENDIO L23 "; // @0x8176
const unsigned char txtL24[] = " INCENDIO L24 "; // @0x8187

const byte conf_boot = 0b00000000; // @0x8198
egipts
Byte
 
Mensagens: 318
Registrado em: 22 Out 2006 01:43
Localização: Mairiporã - SP

Re: Salvar na Flash + CW10 + display 2x16

Mensagempor egipts » 17 Out 2018 16:55

cfreund escreveu:
egipts escreveu:Outra dúvida é de com configuro o NV_FPROT, coloquei apenas " NV_FPROT = 0b00111000 " e não funcionou...


Página 86 @ https://www.nxp.com/docs/en/reference-m ... _Rev.1.pdf

"During the reset
sequence, the FPROT register is loaded with the contents of the flash protection byte in
the flash configuration field at global address 0xFF7C in flash memory. "

Exemplo está no rodapé da página 13: https://www.nxp.com/docs/en/application-note/AN4570.pdf


Olá. Estou usando o exemplo dá página 5 do AN4570 para apagar 512 bytes a partir do 0x8000 mas tá dando erro...

err=0; // erase flash:
NVM_FSTAT = 0x30; // Clear error flags
NVM_FCCOBIX = 0x0; // Write index to specify the command code to be loaded
NVM_FCCOBHI = 0x0A; // FLASH ERASE command
NVM_FCCOBLO = 0; // memory address bits[23:16]
NVM_FCCOBIX = 0x1; // Write index to specify the lower byte memory address bits[15:0] to be loaded
NVM_FCCOB = 0x8000; // Write the lower byte memory address bits[15:0]
NVM_FSTAT = 0x80; // Launch the command
while (!(NVM_FSTAT & NVM_FSTAT_CCIF_MASK));// Wait till command is completed
if(NVM_FSTAT & NVM_FSTAT_ACCERR_MASK) // Check error status
{err = 1;}

Configurei as proteções como abaixo, mas mesmo desligado não funiconou:
const byte flash_security_FSEC @0xFF7F = 0b01000001; // NV_FSEC
const byte flash_security_FPROT @0xFF7C = 0b00111000; // NV_FPROT

Onde estou errando? Em algum ponto do datasheet menciona que tenho os setores 64:127 pra usar, mas no programa recomendado não tem a opção de indicar o numero do setor invés do endereço...

Grato.
egipts
Byte
 
Mensagens: 318
Registrado em: 22 Out 2006 01:43
Localização: Mairiporã - SP

Re: Salvar na Flash + CW10 + display 2x16

Mensagempor egipts » 21 Out 2018 15:03

Que zica...
Eu tinha esquecido de configurar o Click do controlador Flash:
NVM_FCLKDIV = 0x04; // FDIVLD=R FDIVLCK=0 FDIV=000100 (clock from 4,6 to 5,6MHz)

Só que agora invés de dar erro ele tá resetando o chip...

Que que eu faço! Já li e reli os AN4570 e o datasheet e não achei o erro...
egipts
Byte
 
Mensagens: 318
Registrado em: 22 Out 2006 01:43
Localização: Mairiporã - SP

Anterior

Voltar para NXP (ex-FreeScale (ex-Motorola))

Quem está online

Usuários navegando neste fórum: Nenhum usuário registrado e 1 visitante

x