memory page problem on 29466

Discussion and support of the compiler from ImageCraft for the M8C.

Moderator: richard@imagecraft.com

memory page problem on 29466

Postby appavito » Wed Feb 08, 2012 3:22 pm

HI MY CODE IS UNDER.

I set 2 isr for uart, working, my problem is this:
i have flag (volatile unsigned char UcCmdFlag,EthCmdFlag,ServiceCmdFlag;) set upped inside isr.

for example one isr is:

static char Cmd=0,Count=0,DataCount=0;
Cmd=UART_1_cReadChar();
UcCmdFlag=1;
UART_1_PutChar(0x03);

WHEN I SEND ONE CHAR I GIVE REPLU 0X03. INTERRUPT WORKING.

INSIDE WHILE(1) : I CECK THE FLAG STATUS. IF FLAG IS SET TO 1 PUT ONOTHER CHAR ( 0x04 FOR ISR 1 0X02 FOR ISR2)

I WATCH THIS:

IF TOTAL MEMORY USED IS INSIDE PAGE I ALL WORK GOOD ( VOLATILE QUALIFIER NON NECESSARY)

COMPILER CODE: GENERATE WITH SET ONE ARRAY unsigned char CmdUCBuffer[10]; AT 10 BYTE SIZE
ALL WORKING GOOD. I RECEIVE 2 CHAR FOR EVERY CHAR SENDED ( ONE SEND INSIDE ISR , ONE INSIDE WHILE1)
Linking..
LMM info: area 'InterruptRAM' uses 9 bytes in SRAM bank 0
LMM info: area 'data' item of 76 bytes allocated in SRAM page 0
LMM info: area 'data' item of 30 bytes allocated in SRAM page 0
LMM info: area 'data' item of 19 bytes allocated in SRAM page 0
LMM info: area 'data' item of 19 bytes allocated in SRAM page 0
LMM info: area 'data' item of 19 bytes allocated in SRAM page 0
LMM info: area 'data' item of 10 bytes allocated in SRAM page 0
LMM info: area 'data' item of 4 bytes allocated in SRAM page 0
LMM info: area 'data' item of 4 bytes allocated in SRAM page 0
LMM info: area 'data' item of 4 bytes allocated in SRAM page 0
LMM info: area 'data' item of 4 bytes allocated in SRAM page 0
LMM info: area 'data' item of 4 bytes allocated in SRAM page 0
LMM info: area 'virtual_registers' uses 2 bytes in SRAM page 0
LMM info: area 'data' item of 2 bytes allocated in SRAM page 0
LMM info: area 'data' item of 2 bytes allocated in SRAM page 0
LMM info: area 'data' item of 1 bytes allocated in SRAM page 0
LMM info: area 'data' item of 1 bytes allocated in SRAM page 0
LMM info: area 'data' item of 1 bytes allocated in SRAM page 0
LMM info: area 'data' item of 1 bytes allocated in SRAM page 0
LMM info: area 'data' item of 1 bytes allocated in SRAM page 0
LMM info: area 'data' item of 1 bytes allocated in SRAM page 0
LMM info: area 'data' item of 1 bytes allocated in SRAM page 0
LMM info: area 'data' item of 1 bytes allocated in SRAM page 0
LMM info: area 'data' item of 1 bytes allocated in SRAM page 0
LMM info: area 'data' item of 1 bytes allocated in SRAM page 0

BUT IF I SET unsigned char CmdUCBuffer[60]; I RECEIVE ONE CHAR ONLY , ISR CHAR! THE FLAG NEVER SETTED !!!!!
LINKER CODE:


LMM info: area 'InterruptRAM' uses 9 bytes in SRAM bank 0
LMM info: area 'data' item of 76 bytes allocated in SRAM page 0
LMM info: area 'data' item of 50 bytes allocated in SRAM page 0
LMM info: area 'data' item of 30 bytes allocated in SRAM page 0
LMM info: area 'data' item of 19 bytes allocated in SRAM page 0
LMM info: area 'data' item of 19 bytes allocated in SRAM page 0
LMM info: area 'data' item of 19 bytes allocated in SRAM page 0
LMM info: area 'data' item of 4 bytes allocated in SRAM page 0
LMM info: area 'data' item of 4 bytes allocated in SRAM page 0
LMM info: area 'data' item of 4 bytes allocated in SRAM page 0
LMM info: area 'data' item of 4 bytes allocated in SRAM page 0
LMM info: area 'data' item of 4 bytes allocated in SRAM page 0
LMM info: area 'virtual_registers' uses 2 bytes in SRAM page 0
LMM info: area 'data' item of 2 bytes allocated in SRAM page 0
LMM info: area 'data' item of 1 bytes allocated in SRAM page 0
LMM info: area 'data' item of 2 bytes allocated in SRAM page 1
LMM info: area 'data' item of 1 bytes allocated in SRAM page 1
LMM info: area 'data' item of 1 bytes allocated in SRAM page 1
LMM info: area 'data' item of 1 bytes allocated in SRAM page 1
LMM info: area 'data' item of 1 bytes allocated in SRAM page 1
LMM info: area 'data' item of 1 bytes allocated in SRAM page 1
LMM info: area 'data' item of 1 bytes allocated in SRAM page 1
LMM info: area 'data' item of 1 bytes allocated in SRAM page 1
LMM info: area 'data' item of 1 bytes allocated in SRAM page 1
LMM info: area 'data' item of 1 bytes allocated in SRAM page 1


I WATCH THIS WHEN I WRITE ONLY ONE BYTE OF DATA IN SRAM PAGE 1 . FLAG STOP TO WORKING!!!!!!

I ADD UNDER MY CODE: I THINK WHO IS COMPILER PROBLEM IN LARGE MODEL..

if(UcCmdFlag)
{

UART_1_PutChar(0x04);
UcCmdFlag=0;
}
if(EthCmdFlag)
{
UART_2_PutChar(0x02);
EthCmdFlag=0;
}



#include <m8c.h> // Part specific constants and macros
#include "PSoCAPI.h" // PSoC API definitions for all User Modules
#include <stdlib.h>
#include <string.h>



BYTE comm;
volatile unsigned char UcCmdFlag,EthCmdFlag,ServiceCmdFlag;

unsigned char Modello;
unsigned char H[19];
unsigned char Hstato[19];
unsigned char Herror[19];
unsigned long Hquant[19];
unsigned char CmdUCBuffer[10];
unsigned char CmdEtherBuffer[30];
unsigned long CoinIn;
unsigned long CoinOut;
unsigned int Country_code;
unsigned long BillingIn;
unsigned long BillingOut;
unsigned long Prelievo;
unsigned int LimitePrelievo;
const char HWVersion[] ="HW001" ;
const char SWVersion[] ="SW001" ;


void main(void)
{
M8C_EnableGInt;
M8C_EnableIntMask(INT_MSK0,INT_MSK0_GPIO);
//UART_1_CmdReset();
UART_1_IntCntl(UART_1_ENABLE_RX_INT);
UART_1_Start(UART_1_PARITY_NONE);
//UART_2_CmdReset();
UART_2_IntCntl(UART_2_ENABLE_RX_INT);
UART_2_Start(UART_2_PARITY_NONE);
UART_3_IntCntl(UART_3_ENABLE_RX_INT);
UART_3_Start(UART_3_PARITY_NONE);
while(1)
{
if(UcCmdFlag)
{

//PutCmdReceived();
UART_1_PutChar(0x04);
UcCmdFlag=0;
}
if(EthCmdFlag)
{
UART_2_PutChar(0x02);
EthCmdFlag=0;
}
}
}


void UART_1_C(void) // ISR UART_1
{
static char Cmd=0,Count=0,DataCount=0;
Cmd=UART_1_cReadChar();
UcCmdFlag=1;
UART_1_PutChar(0x03);
//CmdCpuBuffer[Count]=Cmd;
}


void UART_2_C(void)
{
static char Cmd=0,Count=0;
Cmd=UART_2_cReadChar();
EthCmdFlag=1;
UART_2_PutChar(0x01);
}
appavito
Cheese Cube
Cheese Cube
 
Posts: 47
Joined: Thu May 27, 2010 2:28 am

Re: memory page problem on 29466

Postby bobmarlowe » Wed Feb 08, 2012 10:53 pm

sorry, but I am really not able to go through your un-indendet code within a completely unknown environment.
To help you with a complex problem like this it would be best if you can upload a complete project that shows the error.

I'm not in the office today, I can have a look at in 12 hours earliest

Happy uploading

Bob
User avatar
bobmarlowe
The Big Cheese
The Big Cheese
 
Posts: 1490
Joined: Thu Oct 06, 2011 2:03 am
Location: Germany

Re: memory page problem on 29466

Postby appavito » Thu Feb 09, 2012 3:58 am

hi many tanks i add project...

REMEMBER WHO I use on interrupt vector lcall UART_1_C not ljmp UART_1_RX_ISR ... when you generate code configuration, lcall is overwrite!

you can open and watch with your eyes... only build with 2 different size of array

for testing you can:
1 volatile unsigned char CmdUCBuffer[30]; set to size =30. in this case you receive on uart 2 char :
one sended inside UART_1_C 0x03
one send inside while 1 : 0x04

while(1)
{
if(UcCmdFlag)
{

//PutCmdReceived();
UART_1_PutChar(0x04);
UcCmdFlag=0;
}

and you can watch who uart work, and volatile flags was setted!! ONLY PAGE 0 USED!

SECOND STEP

1 volatile unsigned char CmdUCBuffer[100]; set to size =100. in this case you receive ONLY ONE char 0X03!! flag never setted!!!!
i think who when start to use more then page ram 0 the error come!!!
Attachments
SerialEthGprs.rar
project with 2 uart..
(529.78 KiB) Downloaded 163 times
appavito
Cheese Cube
Cheese Cube
 
Posts: 47
Joined: Thu May 27, 2010 2:28 am

Re: memory page problem on 29466

Postby slandrum » Thu Feb 09, 2012 5:21 am

If you don't tell the compiler that your ISR function is an interrupt handler, then it won't properly deal with page settings.

When and interrupt is entered, the current paging mode of the device is disabled, so that minimal interrupt routines don't have to alter the page mode settings. Ideally the interrupt code will just deal with page 0. If the interrupt code needs to deal with variables in other pages, then it will need to change the paging mode. If you tell the compiler that your function is an interrupt handler, then you will also need to not use lcall, but instead use ljmp from the vector table, as the function will end with "reti" instruction instead of "ret".
slandrum
The Big Cheese
The Big Cheese
 
Posts: 453
Joined: Fri Feb 29, 2008 11:38 am
Location: California

Re: memory page problem on 29466

Postby appavito » Thu Feb 09, 2012 6:17 am

i need to use lcall for working with more then one uart.

viewtopic.php?f=3&t=8376
appavito
Cheese Cube
Cheese Cube
 
Posts: 47
Joined: Thu May 27, 2010 2:28 am

Re: memory page problem on 29466

Postby appavito » Thu Feb 09, 2012 8:11 am

if i use this ( force adressing at page 0) WORKING.

#pragma abs_address:0x0013 //0x0190 dec 400 not work (page1) 0x0064 dec 100 working
volatile unsigned char UcCmdFlag ={0};
#pragma end_abs_address

#pragma abs_address:0x0014
volatile unsigned EthCmdFlag ={0};
#pragma end_abs_address

#pragma abs_address:0x0015
volatile unsigned ServiceCmdFlag ={0};
#pragma end_abs_address

I ADD MORE TEST VARIABLE FOR USE PAGE 1 AND 2:

unsigned long Hquant1[19];
unsigned long Hquant2[19];
unsigned long Hquant3[19];
unsigned long Hquant4[19];
unsigned long Hquant5[19];
volatile char CmdUCBuffer[24];
volatile char CmdServiceBuffer[24];
volatile unsigned char CmdEtherBuffer[24];


IF I DECLARE THE VARIABLE
volatile unsigned char UcCmdFlag,EthCmdFlagServiceCmdFlag;
NOT WORKING.
WITH ABS ADDRESS WORKING.

NOW FLAG WAS SETTED ALWAYS. BUT I THINK THIS. BUFFER WORK AND IS LOCATE CmdUCBuffer ON PAGE 1 CmdServiceBuffer ON PAGE 2 CmdEtherBufferON PAGE 3 !!!!!! FLAG AND BUFFER ARE MANIPULATE INSIDE ISR... WHY FLAG NOT SETTED AND BUFFER YES????
appavito
Cheese Cube
Cheese Cube
 
Posts: 47
Joined: Thu May 27, 2010 2:28 am

Re: memory page problem on 29466

Postby slandrum » Thu Feb 09, 2012 8:27 am

In general, you should guarantee that variables that are going to be modified by your interrupt handlers are in page 0.

If you really must access variables outside of page 0 in your interrupt handler, you are most likely going to have to write your interrupt handler in assembler to deal with the proper handling of everything.
slandrum
The Big Cheese
The Big Cheese
 
Posts: 453
Joined: Fri Feb 29, 2008 11:38 am
Location: California

Re: memory page problem on 29466

Postby bobmarlowe » Thu Feb 09, 2012 11:30 am

Sorry, but you didn't zip your project, I do not use unraw 'cause it is not totally free and zip is part of windows.
Bob
User avatar
bobmarlowe
The Big Cheese
The Big Cheese
 
Posts: 1490
Joined: Thu Oct 06, 2011 2:03 am
Location: Germany


Return to “%s” ImageCraft ICCv7 for M8C Compiler

Who is online

Users browsing this forum: No registered users and 1 guest

cron