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 CCS Technical Support

PIC16F873

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



Joined: 11 Jul 2006
Posts: 42
Location: Minden, Germany

View user's profile Send private message

PIC16F873
PostPosted: Tue Apr 10, 2007 8:23 am     Reply with quote

Hi all!

My cade, that i made for pic16f877a have no function with pic16f873. A have checked all pins, but it's all ok. I2C have no function and RS232 too. Any ideas?
deniska_gus



Joined: 11 Jul 2006
Posts: 42
Location: Minden, Germany

View user's profile Send private message

PostPosted: Tue Apr 10, 2007 11:24 am     Reply with quote

What i just want to know, if i have a code for pic16f877, what i have to do, that my program will run with pic16f873?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Apr 10, 2007 11:29 am     Reply with quote

1. Create a new project in MPLAB and select the 16F873 as the PIC.

2. Edit your source code and change the #include line to be for 16F873.H.

3. Re-compile the code. Fix any errors.

4. Program it into a 16F873.
deniska_gus



Joined: 11 Jul 2006
Posts: 42
Location: Minden, Germany

View user's profile Send private message

PostPosted: Wed Apr 11, 2007 1:48 am     Reply with quote

Guys, i give up! Here is my code:
Code:

 #include <16F873A.h>
#fuses XT, NOWDT, PROTECT, PUT, BROWNOUT, NOLVP, NOWRT
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_c6, rcv=PIN_c7,parity=n,bits=8,ERRORS)
#use i2c(Master, sda=PIN_C4, scl=PIN_C3, SMBUS)
#define BEEPER    PIN_A0
#define proz_20   PIN_B0
#define proz_40   PIN_B1
#define proz_60   PIN_B2
#define proz_80   PIN_B4
#define proz_100  PIN_B5


int1 alarm=0;
int8 datal, datah,i;
int16 data,data_alt=0;
int16 COMMAND_CODE[15]={0x13, 0x08, 0x09, 0x0B, 0x0D, 0x0F, 0x10,0x11, 0x14,
                                       0x15, 0x17, 0x3C, 0x3D, 0x3E, 0x3F};


void test()
{
  output_high(proz_20);
  output_high(proz_40);
  output_high(proz_60);
  output_high(proz_80);
  output_high(proz_100);
  output_high(BEEPER);
  delay_ms(500);
  output_low(BEEPER);
}

void bq_protokol()
{
 printf("~0000");
 for (i=0; i<=14; i++)
 {
    i2c_start();                          // Start
    i2c_write(0x16);                      //Battery Adress + R/W=0
    i2c_write(COMMAND_CODE[i]);           // Command Word
    i2c_start();                          //  Start
    i2c_write(0x17);                      // Battery Address + R/W=1
    datal=i2c_read();                     // Read + ACK
    datah=i2c_read(0);                    // Read + NACK
    i2c_stop();                            //Stop
    data=make16(datah, datal);
    printf("%6lu", data);
 }
 printf("\r\n");
}



The same code but with PIC 16F877A and #include <16F877A.h> runs. With this PIC not. Can somebody say me please what's wrong.
deniska_gus



Joined: 11 Jul 2006
Posts: 42
Location: Minden, Germany

View user's profile Send private message

PostPosted: Wed Apr 11, 2007 1:49 am     Reply with quote

I get just 15 times 0 from bq_protokol() and not the data
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Apr 11, 2007 2:15 am     Reply with quote

In your posts, you sometimes refer to 16F877 and then to 16F877A.
Also, the same thing for 16F873 and 16F873A.

These chips are not the same. The "A" version is not the same as
the "non-A" version. You must compile for the correct chip, and also
your programmer must be set for the correct chip.



Also, what's your compiler version ?
deniska_gus



Joined: 11 Jul 2006
Posts: 42
Location: Minden, Germany

View user's profile Send private message

PostPosted: Wed Apr 11, 2007 2:20 am     Reply with quote

I have both, pic16f873 and pic16f873A. And i have the same problem with both pic's. Now i'm using pic16f873a and #include<16F873A.h>. Vers. 4.013
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Apr 11, 2007 2:44 am     Reply with quote

To solve this problem I will have to compare the two .LST files for
the 16F877A and the 16F873A. I'll try to do that tomorrow.
deniska_gus



Joined: 11 Jul 2006
Posts: 42
Location: Minden, Germany

View user's profile Send private message

PostPosted: Wed Apr 11, 2007 2:47 am     Reply with quote

Thank you
deniska_gus



Joined: 11 Jul 2006
Posts: 42
Location: Minden, Germany

View user's profile Send private message

PostPosted: Wed Apr 11, 2007 3:25 am     Reply with quote

Dear PCM Programmer,

i just changed SDA from PIN_C4 to PIN_C1 and SCL from PIN_C3 to PIN_C2 and it's runs. But why?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Apr 11, 2007 2:19 pm     Reply with quote

That's a good question. Were you trying to use hardware i2c by adding
the FORCE_HW parameter to the #use i2c() statement, when you had
it set to use pins C4 and C1 ?

Or was it always set for software i2c ? (No FORCE_HW parameter)

Are you using a different test program than the one you posted in
the earlier post ?

----
Also, I don't have vs. 4.013. The closest I have is vs. 4.014.
So if the suggestions above don't provide an answer, then compile
the following test program and verify that it fails. Then compile
it for the 16F877A, and verify that it works. Then PM me both .LST files.
Then I'll just visually compare them and look for any significant differences.
Code:

#include <16F873A.h>
#fuses XT, NOWDT, PROTECT, PUT, BROWNOUT, NOLVP, NOWRT
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_c6, rcv=PIN_c7,parity=n,bits=8,ERRORS)
#use i2c(Master, sda=PIN_C4, scl=PIN_C3, SMBUS)

int1 alarm=0;
int8 datal, datah,i;
int16 data,data_alt=0;

int16 COMMAND_CODE[15]=
 {0x13, 0x08, 0x09, 0x0B, 0x0D,
   0x0F, 0x10, 0x11, 0x14, 0x15,
   0x17, 0x3C, 0x3D, 0x3E, 0x3F};

//--------------------------------
void bq_protokol()
{
 printf("~0000");

 for (i=0; i<=14; i++)
 {
    i2c_start();       // Start
    i2c_write(0x16);   // Battery Adress + R/W=0
    i2c_write(COMMAND_CODE[i]); // Command Word
    i2c_start();       //  Start
    i2c_write(0x17);   // Battery Address + R/W=1
    datal=i2c_read();  // Read + ACK
    datah=i2c_read(0); // Read + NACK
    i2c_stop();        // Stop
    data=make16(datah, datal);
    printf("%6lu", data);
 }

 printf("\r\n");
}
deniska_gus



Joined: 11 Jul 2006
Posts: 42
Location: Minden, Germany

View user's profile Send private message

PostPosted: Thu Apr 12, 2007 2:50 am     Reply with quote

Hello PCM Programmer

It was always set for software i2c. Now i've added the FORCE_HW Parameter and no succes. I will send you 2 list-files. Thank you for all.

Dennis
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Apr 15, 2007 3:33 pm     Reply with quote

I compared the two .LST files and I didn't see any important differences.
The compiler uses different RAM locations for temporary variables in
each listing. That shouldn't cause any problems.
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