|
|
View previous topic :: View next topic |
Author |
Message |
cadrjr Guest
|
Help - "Error 102 : Expect Comma" |
Posted: Tue Dec 09, 2008 9:03 pm |
|
|
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
|
|
Posted: Tue Dec 09, 2008 9:35 pm |
|
|
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
|
|
Posted: Wed Dec 10, 2008 4:57 am |
|
|
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
|
|
Posted: Wed Dec 10, 2008 7:52 am |
|
|
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 ! |
Posted: Wed Dec 10, 2008 6:33 pm |
|
|
Thanks John P ! |
|
|
|
|
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
|