Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Identifier redefined at PIC18F2520

Status
Not open for further replies.

lindodv

Junior Member level 1
Junior Member level 1
Joined
Jul 4, 2014
Messages
16
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
121
Hi all, can you help me solving this problem?
this code is working with PIC16F877A but is not working with PIC18F2520.

Code:
sbit SDA at RC4_bit;
sbit SCL at RC3_bit;
sbit SDA_Direction at TRISC4_bit;
sbit SCL_Direction at TRISC3_bit;

void main() {

   SDA_Direction=0;
   SCL_Direction=0;
   do{
   SDA = 1;
   SCL = 0;
   delay_ms(2000);
   SDA = 0;
   SCL = 1;

  } while(1);

}



0 121 Compilation Started PIC18F2520.c
1 392 'SDA' Identifier redefined PIC18F2520.c
2 401 ; expected, but 'at' found PIC18F2520.c
2 392 'SCL' Identifier redefined PIC18F2520.c
2 370 Specifier needed PIC18F2520.c
2 395 Invalid declarator expected'(' or identifier PIC18F2520.c
3 401 ; expected, but 'at' found PIC18F2520.c
3 370 Specifier needed PIC18F2520.c
3 395 Invalid declarator expected'(' or identifier PIC18F2520.c
3 392 '' Identifier redefined PIC18F2520.c
4 401 ; expected, but 'at' found PIC18F2520.c
4 370 Specifier needed PIC18F2520.c
4 395 Invalid declarator expected'(' or identifier PIC18F2520.c
4 392 '' Identifier redefined PIC18F2520.c
4 312 Internal error '' PIC18F2520.c
0 102 Finished (with errors): 18 Jul 2014, 20:00:20 PIC18F2520.mcppi
 

hello,

if you have included I2C library..
you don't have to redefine SDA SCL ... for I2C
I2C library allready define this bits...

I²C1 module is initialized on the RC3 and RC4 pin (SCL and SDA, respectively).

see your 18F25K20.c file
maybe here :
"C:\Program Files\Mikroelektronika\mikroC PRO for PIC\Defs\P18F25K20.c

be carrefull...

Code:
  // Alternative bit function
    const register unsigned short int SCL = 3;
    sbit  SCL_bit at PORTC.B3;


    // Alternative bit function
    const register unsigned short int SDA = 4;
    sbit  SDA_bit at PORTC.B4;
 
Last edited:

thanks guys, I'm using mikroc for PIC.
this nether code is not working:what's the problem!
Code:
void main() {

   TRISC.B4=0;
   TRISC.B3=0;

   do{
   PORTC.B4 = 1;
   PORTC.B3 = 0;
   delay_ms(2000);
   PORTC.B4 =0;
   PORTC.B3 =1;

  } while(1);

}

in the simulator, LEDs are not blinking.
 
Last edited:

hello,


the rule is : with PIC18F use LAT instead PORT for output..
and it is better to add a delay to see the change

Code:
void main() {

   TRISC.B4=0;
   TRISC.B3=0;

   do{
   LATC.B4 = 1;
   LATC.B3 = 0;
   delay_ms(2000);
   LATC.B4 =0;
   LATC.B3 =1;
 [B][COLOR=#0000ff] delay_ms(2000);[/COLOR][/B]  


  } while(1);
}
 

oh my....I can see my stupid mistake here.(delay_ms)thanks.
I could solve my previous problem with this code:
Code:
sbit SSDA at RC4_bit;
sbit SSCL at RC3_bit;
sbit SSDA_Direction at TRISC4_bit;
sbit SSCL_Direction at TRISC3_bit;

void main() {


   SSDA_Direction=0;
   SSCL_Direction=0;
   do{
   SSDA = 1;
   SSCL = 0;
   delay_ms(2000);
   SSDA = 0;
   SSCL = 1;
   delay_ms(2000);
  } while(1);

}
but it's a Trick.when I disabled I2C Library the error did not disappear (Identifier redefined), so I used the Trick. Do you have any simply example with PIC18F for I2C communication(Compatible with Mikroc PIC)?
 
Last edited:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top