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

Help - "Error 102 : Expect Comma"

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







Help - "Error 102 : Expect Comma"
PostPosted: Tue Dec 09, 2008 9:03 pm     Reply with quote

I want to insert a little ASM into my C program.
When I try to compile the following, I get an "Error 102 : Expect Comma" error after the BSF instruction.

What am I doing wrong ?
Code:
void ser_init() {
#asm        SER_INIT:
            BSF     STATUS,5           ; select bank 1
            BCF     TRISB,1            ; set B1 as an output
            BCF     STATUS,5           ; select bank 0
            BCF     PORTB,1            ; set B1 low
            RETURN
#endasm
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Dec 09, 2008 9:35 pm     Reply with quote

Post the statements in which you declare 'STATUS', 'TRISB', and 'PORTB'.
Also post your PIC and your compiler version.

A few more comments:
Quote:
#asm SER_INIT:
BSF STATUS,5 ; select bank 1
BCF TRISB,1 ; set B1 as an output
BCF STATUS,5 ; select bank 0
BCF PORTB,1 ; set B1 low
RETURN
#endasm

1. The compiler knows which banks the TRISB and PORTB registers are in.
It will automatically insert ASM code to select the correct bank. It will
do this even within an #asm block (unless you tell it not to, with an ASIS
statement). Remove the lines that set the bank.


Quote:
#asm SER_INIT:
BSF STATUS,5 ; select bank 1
BCF TRISB,1 ; set B1 as an output
BCF STATUS,5 ; select bank 0
BCF PORTB,1 ; set B1 low
RETURN
#endasm

2. The 'return' statement is a mistake. This will cause a premature return
from the function. The compiler inserts clean-up code at the end of
the function, before it does its own return statement. Delete that line.


3. Your entire ASM routine can be done much more easily, efficiently,
safely (i.e, more error free) and in a more portable way, with this
single line of code:
Code:
output_low(PIN_B1);


You can discover all these things by looking at the .LST file. It's in your
project directory, after a successful build.
Guest








PostPosted: Wed Dec 10, 2008 4:57 am     Reply with quote

Hi,
thanks for these pointers.
I've now trimmed everything down to the code below - which still gives the "Error 102 : Expect Comma" error.

I have many programs working fine in CCS C. Unfortunately I now need to insert a little code at ASM level to achieve what I need. This is my first time to try to incorporate ASM code in this way.

Code:

#include  <16F87.h>

#use      delay(clock=10000000, RESTART_WDT)
#fuses    HS, PUT, BROWNOUT, WDT, MCLR, NOLVP, PROTECT

#USE      FAST_IO(B)
#USE      FAST_IO(A)

#DEFINE   TRISB          0x06          ;
#DEFINE   PORTB          0x06          ;


void ser_init() {
#asm        SER_INIT:
            BCF     TRISB,1           
            BCF     PORTB,1           
#endasm
}

void main()
   {

   
    //
    //
    //
    //
   
   
 }
John P



Joined: 17 Sep 2003
Posts: 331

View user's profile Send private message

PostPosted: Wed Dec 10, 2008 7:52 am     Reply with quote

Hey, I get to be the one to say it--

Code:

#DEFINE TRISB 0x06 ;
#DEFINE PORTB 0x06 ;


There should NOT be a semicolon at the end of those lines.
cadrjr
Guest







Thanks !
PostPosted: Wed Dec 10, 2008 6:33 pm     Reply with quote

Thanks John P !
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