PSoC >> PSoC Mixed-Signal Array

Pages: 1
IceCube
Tester - PRO for PSoC
***

Reged: Jun 27 2007
Posts: 86
Loc: The Netherlands
#define macro
      #63472 - Wed Jul 02 2008 06:08 PM

Hi,

I try to do this:
Code:
#define SSC(function)		asm("mov X,SP");asm("mov A,X");asm("add A,3");asm("mov [249],A");asm("mov [248],58");asm("mov A,_function");asm("SSC")

It is obvious this does not work. I know there is a ssc intruction in psoc.h and one in m8c.inc but I like to know how to do this within the c-compiler.

Regards, Rolf


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

Reged: Oct 16 2003
Posts: 633
Re: #define macro [Re: IceCube]
      #63532 - Thu Jul 03 2008 01:10 AM

Rolf, I assume when you say it doesn't work, you're referring to the failure to substitute the "function" argument in the macro?

If so, that's because you need to use the (ANSI C Standard) stringization operator #, e.g.

Code:

#define SSC(function) asm("mov X,SP");\
asm("mov A,X");\
asm("add A,3");\
asm("mov [249],A");\
asm("mov [248],58");\
asm("mov A," #function );\
asm("SSC")

main()
{
SSC(12);
}



But I recommend using the built-in __ssc() pseudo-function anyway.

Clyde


Post Extras: Print Post   Remind Me!   Notify Moderator  
IceCube
Tester - PRO for PSoC
***

Reged: Jun 27 2007
Posts: 86
Loc: The Netherlands
Re: #define macro [Re: clyde]
      #63572 - Thu Jul 03 2008 05:08 AM

Thank you Clyde, that is what I meant.

I am writing a UART bootloader and I want to include as less as possible.

Regards, Rolf


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

Reged: Oct 16 2003
Posts: 633
Re: #define macro [Re: IceCube]
      #63622 - Thu Jul 03 2008 07:48 AM

The built-in __ssc() pseudo-function produces exactly the same code you have in your macro, with the advantage that the argument can be any C expression.

Post Extras: Print Post   Remind Me!   Notify Moderator  
IceCube
Tester - PRO for PSoC
***

Reged: Jun 27 2007
Posts: 86
Loc: The Netherlands
Re: #define macro [Re: clyde]
      #63772 - Thu Jul 03 2008 05:06 PM

Yes Clyde, I know.

When I was looking at the flash.c source I saw something strange:
Code:
	if(_flash_banks != 0)
FLS_PR1 = 0; // tables are in bank 0.
__ssc(TableRead);

and Code:
	if(_flash_banks != 0) {
FLS_PR1 = blockno/BLOCKS_PER_BANK;
BLOCKID = blockno % BLOCKS_PER_BANK;
} else
BLOCKID = blockno;
__ssc(EraseBlock);


Shouldn't this be:
Code:
	if(_flash_banks != 1) { ...


Regards, Rolf


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

Reged: Oct 16 2003
Posts: 633
Re: #define macro [Re: IceCube]
      #63782 - Thu Jul 03 2008 05:11 PM

Good pickup! Fortunately it's harmless, other than generating some unnecessary moves on single-bank chips.

I've updated the source, that will appear in the next build.

Clyde


Post Extras: Print Post   Remind Me!   Notify Moderator  
Pages: 1



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

Moderator:  ndouglas, Dan Henry, jtemples, jeff, Andrew L, mikerj, dave g, meisty, josh stevo 

Print Topic

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

Rating:
Topic views: 1032

Rate this topic

Jump to

Contact Us | Privacy statement HI-TECH Software

Powered by UBB.threads™ 6.5.5