CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

The variables after the 0x60 RAM address.
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
restman
Guest







The variables after the 0x60 RAM address.
PostPosted: Tue Nov 27, 2007 6:44 am     Reply with quote

Hi.

I can not use the variables after the 0x60 RAM address on 18f4620. I have a lot of variables above 0x60 number. How can i fix this situation?

Thanks for your helps.
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

View user's profile Send private message Visit poster's website

PostPosted: Tue Nov 27, 2007 8:59 am     Reply with quote

I can.
Code:
#include <18F4620.h>
#fuses hs,wdt32,noprotect,nolvp,put
#use delay(clock=18432000,RESTART_WDT)
#use rs232(baud=19200,xmit=PIN_B3,invert,stream=debug)
#use rs232(xmit=PIN_C6,rcv=PIN_C7,enable=PIN_C5,baud=1200,bits=8,parity=e,errors,stream=CIM)
#case
#zero_ram
int8 var;
#byte var=0x61 //note no semicolin
//====prototype=====//
void init(void);
//========================= Main ====================================//
void main(void)
{
  init();
  while(1)
  {
    fprintf(DEBUG,"var=%u\n\r",var);
    restart_wdt();
  }
}
//========================= Functions ==============================//
//=== init ===//  setup the initial settings
void init(void){
  int8 tmp;
  setup_wdt(WDT_ON);
  setup_adc_ports(NO_ANALOGS);
  setup_adc(ADC_OFF);
  set_tris_a(0);set_tris_e(0);set_tris_c(0xFF);
  set_tris_b(0xFF);
  port_b_pullups(TRUE);
  enable_interrupts(GLOBAL);
  fprintf(DEBUG,"START\n\r");
  restart_wdt();
}


Perhaps showing us your code, or giving more info can help us solve your problem. You have a TON of ram on the 18F4620 (??64K flash) If you could only use 0-0x60 we would be in very deep trouble.

Did you mean flash, or sram, or EEPROM?
restman
Guest







PostPosted: Tue Nov 27, 2007 9:42 am     Reply with quote

I tried this solution but it didn't work.

The compiler allocates the 0x60 data Memory address for the variable but when i use it in my program, the program doesn't work properly. But when i use the variable before the 0x60 adress, it works. i don't know if i miss smth. I suspect indirect addressing mode but i can't figure what the real problem is.

Thanks for your helps.
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

View user's profile Send private message Visit poster's website

PostPosted: Tue Nov 27, 2007 10:24 am     Reply with quote

Show your program.
restman
Guest







PostPosted: Tue Nov 27, 2007 12:06 pm     Reply with quote

The program's size is approximately 8kb (program memory) and it's a commercial program. Here is an example:

...
...
int8 var1; ---> Data Memory address is 0x59
int8 var2; ---> Data Memory address is 0x60
int8 var3; ---> Data Memory address is 0x61
...
...

the program segment is something like:

if(var2 == 5)
{
...
}
else
{
...
}

When i use var1, the program works properly, but when using var2 or var3 it always skips the if statement and jumps to the else statement.
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

View user's profile Send private message Visit poster's website

PostPosted: Tue Nov 27, 2007 12:28 pm     Reply with quote

So this is just a guess..
I searched the spec for 0x60. I noted that it is used for indexed literal offset addressing mode. Could it be something like that??
tho CCS compiler isn't using the extended instructions as far as I know.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Nov 27, 2007 12:36 pm     Reply with quote

As Treitmey says, make sure you don't have 'XINST' in your #fuses
statement. The code will behave in strange ways if you have that fuse.
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Tue Nov 27, 2007 12:42 pm     Reply with quote

Even better, make sure to set NOXINST on the fuses list. Some compiler versions default to enabling the extended instruction set when the fuse is not specified.
restman
Guest







PostPosted: Tue Nov 27, 2007 3:59 pm     Reply with quote

It is not important whether i write NOXINST or XINST. The compiler always writes NOXINST in lst file. It doesn't change anything. Thanks everyone for helps.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Nov 27, 2007 4:05 pm     Reply with quote

1. Post your compiler version.

2. Can you write a small test program that shows the problem ?
Or does it only occur with a large program ?
restman
Guest







PostPosted: Wed Nov 28, 2007 4:42 am     Reply with quote

1. CCS PCH C Compiler, Version 4.023

2. This is a very simple example:

Code:

#include <18f4620.h>
#fuses NOXINST, HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)

#byte   var1 = 0x60
#byte   var2 = 0x5F

main()
{
   set_tris_b(0xFF);
   set_tris_d(0x00);
   
   var1 = 0xF1;
   var2 = 0x12;
   
   while(true)
   {
      output_d(var1);
      delay_ms(1000);
      output_d(var2);
      delay_ms(1000);
   }
}


In this example var1 appears at portd but var2 doesn't.
restman
Guest







PostPosted: Wed Nov 28, 2007 4:43 am     Reply with quote

Very sorry. var2 appears at portd but var1 doesn't.
Ttelmah
Guest







PostPosted: Wed Nov 28, 2007 5:23 am     Reply with quote

Without looking any further, keyword in the post, Version number 4.023.
Look at the "Version 4 comments" thread at the top of the forum.
I'd not bother trying anything else, before getting a latter version than this. The .02x versions, have major problems.
The oldest version I have kept (I threw away the versions before this), is 4.027, and it runs fine on this.

Best Wishes
restman
Guest







PostPosted: Wed Nov 28, 2007 6:15 am     Reply with quote

I tried with CCS PCH C Compiler, Version 4.057. But the result is the same. Would you please write here the lst file. I want to compare with mine.
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

View user's profile Send private message Visit poster's website

PostPosted: Wed Nov 28, 2007 10:11 am     Reply with quote

Is there a reason to #byte the variables to a location 60,61,...
This is usually only done to access a special function register,... ie portD
I still think it has got to be about the indirect addressing mode and extended instruction set.
Can you show the list file from sample program?
Code:
CCS PCH C Compiler, Version 3.249, 30995               28-Nov-07 09:23

               Filename: C:\ccs\Projects\CRI\jnk.lst

               ROM used: 122 bytes (0%)
                         Largest free fragment is 65414
               RAM used: 6 (0%) at main() level
                         7 (0%) worst case
               Stack:    1 locations

*
00000:  GOTO   002A
.................... #include <18f4620.h>
.................... //////// Standard Header file for the PIC18F4620 device ////////////////
.................... #device PIC18F4620
.................... #list
.................... 
.................... #fuses NOXINST, HS,NOWDT,NOPROTECT,NOLVP
.................... #use delay(clock=20000000)
00004:  CLRF   FEA
00006:  MOVLW  07
00008:  MOVWF  FE9
0000A:  MOVF   FEF,W
0000C:  BZ    0028
0000E:  MOVLW  06
00010:  MOVWF  01
00012:  CLRF   00
00014:  DECFSZ 00,F
00016:  BRA    0014
00018:  DECFSZ 01,F
0001A:  BRA    0012
0001C:  MOVLW  7B
0001E:  MOVWF  00
00020:  DECFSZ 00,F
00022:  BRA    0020
00024:  DECFSZ FEF,F
00026:  BRA    000E
00028:  RETLW  00
.................... 
.................... #byte   var1 = 0x60
.................... #byte   var2 = 0x5F
.................... 
.................... main()
.................... {
0002A:  CLRF   FF8
0002C:  BCF    FD0.7
0002E:  CLRF   FEA
00030:  CLRF   FE9
00032:  MOVF   FC1,W
00034:  ANDLW  C0
00036:  IORLW  0F
00038:  MOVWF  FC1
0003A:  MOVLW  07
0003C:  MOVWF  FB4
....................    set_tris_b(0xFF);
0003E:  MOVLW  FF
00040:  MOVWF  F93
....................    set_tris_d(0x00);
00042:  MOVLW  00
00044:  MOVWF  F95
.................... 
....................    var1 = 0xF1;
00046:  MOVLW  F1
00048:  MOVWF  60
....................    var2 = 0x12;
0004A:  MOVLW  12
0004C:  MOVWF  5F
.................... 
....................    while(true)
....................    {
....................       output_d(var1);
0004E:  CLRF   F95
00050:  MOVFF  60,F8C
....................       delay_ms(1000);
00054:  MOVLW  04
00056:  MOVWF  06
00058:  MOVLW  FA
0005A:  MOVWF  07
0005C:  RCALL  0004
0005E:  DECFSZ 06,F
00060:  BRA    0058
....................       output_d(var2);
00062:  CLRF   F95
00064:  MOVFF  5F,F8C
....................       delay_ms(1000);
00068:  MOVLW  04
0006A:  MOVWF  06
0006C:  MOVLW  FA
0006E:  MOVWF  07
00070:  RCALL  0004
00072:  DECFSZ 06,F
00074:  BRA    006C
....................    }
00076:  BRA    004E
.................... }
00078:  SLEEP

Configuration Fuses:
   Word  1: 0200   HS NOIESO NOFCMEN RESERVED
   Word  2: 1E1F   BROWNOUT NOWDT BORV21 NOPUT WDT32768
   Word  3: 8300   CCP2C1 PBADEN NOLPT1OSC MCLR RESERVED
   Word  4: 0081   STVREN NODEBUG NOLVP NOXINST RESERVED
   Word  5: C00F   NOPROTECT NOCPD NOCPB
   Word  6: E00F   NOWRT NOWRTD NOWRTC NOWRTB
   Word  7: 400F   NOEBTR NOEBTRB
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group