8051 >> HI-TECH C PRO for the Silicon Labs 8051 MCU Family

Pages: 1 | 2 | >> (show all)
atul
Tester
**

Reged: Jun 22 2008
Posts: 5
Macro size constraints
      #62202 - Wed Jun 25 2008 02:00 PM

Macro string size can not be more than 31 characters.

I had two macros in my code

#define DEFAULT_CONTINOUS_MEMORY_HEADER_SECT 1
#define DEFAULT_CONTINOUS_MEMORY_HEADER_PAGE 4

when I compile code with Hitech it gives me Warning (111) of redefinition, while same macros works good with SDCC compiler.

Any Idea??


Post Extras: Print Post   Remind Me!   Notify Moderator  
Dan Henry
Guru
****

Reged: Oct 16 2003
Posts: 3401
Loc: Boulder, Colorado U.S.A.
Re: Macro size constraints [Re: atul]
      #62242 - Wed Jun 25 2008 07:52 PM

Quote:

Any Idea??



Check the "-N" C51 driver option described in the manual.


Post Extras: Print Post   Remind Me!   Notify Moderator  
atul
Tester
**

Reged: Jun 22 2008
Posts: 5
Re: Macro size constraints [Re: Dan Henry]
      #62522 - Fri Jun 27 2008 06:50 AM

OK, -N option works OK , but default 31 is too low size,

One more problem now, I want to increment value of content pointed by a pointer but that does not work the way Kernighan & Rictchie describes e.g.
Code:

++*ptr; // Unable to evaluate expression in HiTech, works fine in SDCC

++(*ptr); // Unable to evaluate expression in HiTech, works fine in SDCC

(*prt)++; // Unable to evaluate expression in HiTech, works fine in SDCC

*ptr += 1; // Unable to evaluate expression in HiTech
*ptr + 1; // Compiles OK in Hitech and SDCC but not sure about the result


Any idea what is the correct way to increment content pointed by a pointer compatible across compilers.

- Atul


Post Extras: Print Post   Remind Me!   Notify Moderator  
Dan Henry
Guru
****

Reged: Oct 16 2003
Posts: 3401
Loc: Boulder, Colorado U.S.A.
Re: Macro size constraints [Re: atul]
      #62562 - Fri Jun 27 2008 09:58 AM

Quote:

Any idea what is the correct way to increment content pointed by a pointer compatible across compilers.



Code:
unsigned char c;

void main(void)
{
unsigned char *p = &c;

++*p;

for (;;);
}


Compiles OK here, but my beta has expired, so no OCG in case that makes a difference.


Post Extras: Print Post   Remind Me!   Notify Moderator  
clydeAdministrator
HI-TECH team member
*****

Reged: Oct 16 2003
Posts: 633
Re: Macro size constraints [Re: atul]
      #62722 - Sat Jun 28 2008 02:17 AM

1) The reason the default identifier size is set at 31 is because this is the minimum required by the ANSI standard for external identifiers. A program that requires more significant characters than this cannot be a conforming ANSI C program, since there may be conforming compilers that will not compile that program.

This policy is fairly long-standing - it may be time to review it. There are probably few compilers now in common use that don't allow more than 31 characters.

2) It's impossible to tell from your post what might be the problem with the pointer arithmetic. Could you please post an example with enough detail to reproduce the problem, and also say what the actual error message is ("unable to evaluate" is not a message the compiler produces, AFAIK)

Regards, Clyde


Post Extras: Print Post   Remind Me!   Notify Moderator  
clydeAdministrator
HI-TECH team member
*****

Reged: Oct 16 2003
Posts: 633
Re: Macro size constraints [Re: Dan Henry]
      #62732 - Sat Jun 28 2008 02:18 AM

Dan, the beta serial number has been extended to the end of July. Just reactivate.

Clyde


Post Extras: Print Post   Remind Me!   Notify Moderator  
atul
Tester
**

Reged: Jun 22 2008
Posts: 5
Re: Macro size constraints [Re: clyde]
      #62752 - Sat Jun 28 2008 11:15 AM Attachment (29 downloads)

I am using c8051f411 MCU having 0x7FF XRAM. When I compiled my code with Hi-Tech compiler, it fails saying could not allocate 0x792 bytes in 'bss' segment which is XDATA.

Find the assembly file generated out of compilation for reference.

Please help why I am getting this error.


Post Extras: Print Post   Remind Me!   Notify Moderator  
Dan Henry
Guru
****

Reged: Oct 16 2003
Posts: 3401
Loc: Boulder, Colorado U.S.A.
Re: Macro size constraints [Re: clyde]
      #62762 - Sat Jun 28 2008 12:42 PM

Thanks. I should have been paying closer attention.

Post Extras: Print Post   Remind Me!   Notify Moderator  
clydeAdministrator
HI-TECH team member
*****

Reged: Oct 16 2003
Posts: 633
Re: Macro size constraints [Re: atul]
      #62862 - Sun Jun 29 2008 09:47 PM

The current beta doesn't allocate the first 100h bytes of XDATA. This has been changed since. We expect to post a new beta version this week with this and numerous other improvements.

Clyde


Post Extras: Print Post   Remind Me!   Notify Moderator  
atul
Tester
**

Reged: Jun 22 2008
Posts: 5
Re: Macro size constraints [Re: clyde]
      #63042 - Mon Jun 30 2008 10:16 AM

Quote:


2) It's impossible to tell from your post what might be the problem with the pointer arithmetic. Could you please post an example with enough detail to reproduce the problem, and also say what the actual error message is ("unable to evaluate" is not a message the compiler produces, AFAIK)

Regards, Clyde




Here is exact Error Message that comes during Linking

C51.exe --chip=c8051f411 --Output=eomf51 main.p1 powerup.obj uart.p1 ADC.p1 RTC.p1 Timer.p1 Util.p1 blackBox.p1 spi.p1
HI-TECH C 51-Pro Pro beta build 2241 V9.70
Copyright (C) 1984-2008 HI-TECH SOFTWARE
Serial number: HC51P-117069242
this licence will expire on Wed, 30 Jul 2008
Totalrefs = 1996
spi.c: 177: (712) can't generate code for this expression
(908) exit status = 1

and part of the code where it points as line no 177 is as:

Code:
 	for(g_bySPIIndex = 0; g_bySPIIndex < 128; g_bySPIIndex++)
{ // Send Data through SPI for up to a Page
g_wSPIIndex = g_pwSPIDataBuffer[*g_pwSPIReadPointer];// Fetch a WORD from Buffer

SPI0DAT = (BYTE)(g_wSPIIndex&0xFF); // LSB
while (SPIF == 0) ; // Wait till byte transmitted
SPIF = 0; // Clear Interrupt Flag

SPI0DAT = (BYTE)((g_wSPIIndex>>8)&0xFF); // MSB
while (SPIF == 0) ; // Wait till byte transmitted
SPIF = 0; // Clear Interrupt Flag
++*g_pwSPIReadPointer; // Linker Error in this line
//(*g_pwSPIReadPointer) + 1; // Work OK
if(*g_pwSPIReadPointer >= g_wSPIReadMaxLimit)
{ // Reverse Buffer Traversal, when it reached to Max
*g_pwSPIReadPointer = 0;
}
}



Pointer type is initialized as
Code:
	WORD *g_pwSPIReadPointer;	// Pointer to content for Data buffer Read Pointer 



and the same is made as extern also like
Code:
 extern  WORD *g_pwSPIReadPointer;	// Pointer to content for Data buffer Read Pointer 



Best Regards
Atul


Post Extras: Print Post   Remind Me!   Notify Moderator  
Pages: 1 | 2 | >> (show all)



Extra information
0 registered and 0 anonymous users are browsing this forum.

Moderator:  Andrew L, clyde, Brent W, jeff, dave g, meisty, josh stevo 

Print Topic

Forum Permissions
      You cannot start new topics
      You cannot reply to topics
      HTML is disabled
      UBBCode is enabled

Rating:
Topic views: 2119

Rate this topic

Jump to

Contact Us | Privacy statement HI-TECH Software

Powered by UBB.threads™ 6.5.5