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 support@ccsinfo.com

Inline assembly question with PCWHD CCS C compiler 4.071

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
klanglais



Joined: 28 Mar 2008
Posts: 6
Location: 70 Industrial Way Wilmington, ma 01887

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

Inline assembly question with PCWHD CCS C compiler 4.071
PostPosted: Thu Apr 10, 2008 6:30 am     Reply with quote

I built the PIC24H Demo code for Explorer 16 Board that came with my Microchip Explorer 16 Board using the Microchip C 30 compiler. Now I am porting the code to the CCS C compiler. So far so good.

Problem:
I am getting the following error.

Executing: "C:\Program Files\PICC\Ccsc.exe" +FD "delay.c" +EXPORT +DF +LN +T +A +M +Z +ICD +Y=0 +EA I+="..\h"
*** Error 95 "delay.c" Line 51(3,5): Expecting an opcode mnemonic _temp_count

********************
This is the original code in delay.c

unsigned int temp_count;

void Delay( unsigned int delay_count )
{
temp_count = delay_count +1;
asm volatile("outer: dec _temp_count");
asm volatile("cp0 _temp_count");
asm volatile("bra z, done");
asm volatile("repeat #3200" );
asm volatile("nop");
asm volatile("repeat #3200" );
asm volatile("nop");
asm volatile("bra outer");
asm volatile("done:");
}

******************************
I changed it to:

unsigned int temp_count;

void Delay( unsigned int delay_count )
{
temp_count = delay_count +1;
#asm
outer:
dec _temp_count
cp0 _temp_count <= this is line 51
bra z, done
repeat #3200
nop
repeat #3200
nop
bra outer
done:
#endasm
}

************************

Any ideas?
Thanks
Ken
Question
ckielstra



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

View user's profile Send private message

PostPosted: Thu Apr 10, 2008 7:17 am     Reply with quote

I suggest you use the CCS supplied functions delay_us() and delay_ms(). These function names are more descriptive than the Microchip delay() and delay_us() combination. Also in CCS style you can call the function directly with the desired delay instead of having to use a defined value.
Code:
Microchip style:
   #define Delay_5mS_Cnt     (Fcy * 0.005) / 2950
   Delay(Delay_5mS_Cnt);     // 5ms delay

CCS style:
   delay_ms(5);              // code self explaining, no description needed.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
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