Jump to content

fischp

EstablishedMember
  • Content Count

    9
  • Joined

  • Last visited

Community Reputation

0 Neutral

About fischp

  • Rank
    Newbrie
  1. Gentlemen, The i2c example program in the C/BoostC directory fails to compile for me. I'm using SB 5.9.7 with all of the latest patches. I've tried several different PICs including the 16f767 and some higher end 18fs. When I complile the program I get: BoostC Optimizing C Compiler Version 2.2.5 Beta (for PIC18 architecture) http://www.picant.com/c2c/c.html Copyright© 2004-2005 Pavel Baranov Copyright© 2004-2005 David Hobday line 70: Illegal redefinition of symbol: PORTC line 71: Illegal redefinition of symbol: TRISC 2 errors detected Error: preprocessing error failure Exit code was 1. Removing target: I2C_Test.obj Failed to locate output file 'I2C_Test.obj' Done Failed Help! Thanks! P.S. Here's the source code: //////////////////////////////////////////////////////////////////////////// // I2C Communications Test Program // // Exercises the i2c driver code in <i2c_driver.h> by demonstrating // reading and writing to an External EEPROM //////////////////////////////////////////////////////////////////////////// // Author(s): Andrew Smallridge // Date 15 November 2004 // // Copyright © 2004-2005 Andrew Smallridge // Copyright © 2004-2005 Pavel Baranov // Copyright © 2004-2005 David Hobday //////////////////////////////////////////////////////////////////////////// #pragma CLOCK_FREQ 40000000 #include <system.h> #include <i2c_driver.h> //////////////////////////////////////////////////////////////////////////// // i2c master hardware / software mode definition // // For i2c hardware support comment out the #define use_ic2_SW line //////////////////////////////////////////////////////////////////////////// //#define use_i2c_SW // #if defined use_i2c_SW //////////////////////////////////////////////////////////////////////////// // i2c software implementation template arguments //////////////////////////////////////////////////////////////////////////// #define i2c_ARGS 3, PORTC, TRISC, 4, PORTC, TRISC, e_SSPCON1, e_SSPCON2, \ e_SSPSTAT, e_SSPBUF, e_SSPIF_BIT, e_SSPIF_PIR, \ e_BCLIF_BIT, e_BCLIF_PIR, 7, e_SSPADD, (i2c_reset_wdt | i2c_SMP) // RAM used by the software i2c driver to emulate the equivalent i2c hardware registers unsigned short swi2c_SSPCON1@0x40; // define location for the emulated SSPCON1 unsigned short swi2c_SSPCON2@0x41; // define location for the emulated SSPCON2 unsigned short swi2c_SSPSTAT@0x42; // define location for the emulated SSPSTAT unsigned short swi2c_SSPBUF@0x43; // define location for the emulated SSPBUF unsigned short swi2c_SSPIF_PIR@0x44;// define location for the emulated SSPIF_PIR unsigned short swi2c_BCLIF_PIR@0x45;// define location for the emulated BCLIF_PIR unsigned short swi2c_SSPADD@0x46; // define location for the emulated SSPADD // variables cannot be passed as template arguments. The following constants map to // the PIC registers and software emalated i2c RAM locations. These constants are // then used by the templated functions. When changing the address of an emulated // register the corresponding constant mapping must also be changed. #define PORTC 0x0f82 #define TRISC 0x0f94 #define e_SSPCON1 0x40 #define e_SSPCON2 0x41 #define e_SSPSTAT 0x42 #define e_SSPADD 0x43 #define e_SSPBUF 0x44 #define e_SSPIF_PIR 0x45 #define e_BCLIF_PIR 0x46 #define e_SSPIF_BIT 3 #define e_BCLIF_BIT 3 #else //////////////////////////////////////////////////////////////////////////// // i2c hardwareware implementation template arguments //////////////////////////////////////////////////////////////////////////// #define i2c_ARGS 3, PORTC, TRISC, 4, PORTC, TRISC, e_SSPCON1, e_SSPCON2, \ e_SSPSTAT, e_SSPBUF, e_SSPIF_BIT, e_SSPIF_PIR, \ e_BCLIF_BIT, e_BCLIF_PIR, 7, e_SSPADD, (i2c_reset_wdt | i2c_SMP |i2c_HW) // variables cannot be passed as template arguments. The following constants map to // the PIC registers and PIC's i2c register locations. These constants are // then used by the templated functions. #define PORTC 0x0f82 #define TRISC 0x0f94 #define e_SSPCON1 0xfc6 #define e_SSPCON2 0xfc5 #define e_SSPSTAT 0xfc7 #define e_SSPADD 0xfc8 #define e_SSPBUF 0xfc9 #define e_SSPIF_PIR 0xf9e #define e_BCLIF_PIR 0xfa1 #define e_SSPIF_BIT 3 #define e_BCLIF_BIT 3 #endif //////////////////////////////////////////////////////////////////////////// // TEST CODE - I2C Device constants //////////////////////////////////////////////////////////////////////////// // define External EEPROM I2C slave (Hardware) addresses #define xee_slave 0xA0 // Base address of 24C512 EEPROM //////////////////////////////////////////////////////////////////////////// // Read from the External EEPROM //////////////////////////////////////////////////////////////////////////// // s is a pointer to the destination buffer to data read from the EEPROM // HW_address is the hardware address of the i2c device // ic2_addr is the target internal address within the External EEPROM // count is the number of bytes to be read starting at i2c_addr void read_XEE(char *s, char HW_address, unsigned short i2c_addr, unsigned short count) { short i; i2c_start(); i2c_write(HW_address); // send XEE i2c address i2c_write(i2c_addr >> 8); // send XEE internal HIGH address i2c_write((char) i2c_addr & 0x00ff); // send XEE internal LOW address i2c_restart(); // send i2c_restart // sending XEE read command via i2c_write i2c_write(HW_address | 0x01); // send device address + RD to I2C device // XEE read loop for (i=0;i<count-1;i++) *s++ = i2c_read(0); *s++ = i2c_read(1); *s = 0; i2c_stop(); } //////////////////////////////////////////////////////////////////////////// // Write to the External EEPROM //////////////////////////////////////////////////////////////////////////// // s is a pointer to the string to be written to the EEPROM // HW_address is the hardware address of the i2c device // ic2_addr is the target internal address within the External EEPROM // count is the number of bytes to be written starting at i2c_addr void write_XEE(char *s, char HW_address, unsigned short i2c_addr, unsigned short count) { short i; i2c_start(); i2c_write(HW_address); // send XEE i2c address i2c_write(i2c_addr >> 8); // send XEE internal HIGH address i2c_write((char) i2c_addr & 0x00ff); // send XEE internal LOW address // XEE write loop for (i=0;i<count;i++) i2c_write(*s++); i2c_stop(); } //////////////////////////////////////////////////////////////////////////// // Return the length of a string //////////////////////////////////////////////////////////////////////////// char strlen(char *s) { char i; for (i = 0; *s != 0; i++) s++; return(i); } void main() { char buffer[32]; char *mesg = "i2c Test String"; char *s1; char i; unsigned short i2c_addr; // used for internal addressing for the target I2C device #define I2C_divisor 0x7E // set the divisor for the I2C clock // for software I2C emulation this can be any value (such as 1) i2c_init(I2C_divisor); // demonstrating a write to address 0x0210 in External EEPROM i2c_addr = 0x0210; write_XEE(mesg, xee_slave, i2c_addr, strlen(mesg)+1); // The External EEPROM requires a delay to finish // programming the flash before it can be accessed again delay_ms(10); // demonstrating a read 16 bytes from address 0x0214 in External EEPROM i2c_addr = 0x0214; s1 = buffer; // point s1 to the work buffer read_XEE(s1, xee_slave, i2c_addr, 16); while (1); }
  2. IDE 5.8 BoostC v1.9.2 PIC 16F627 @ 4MHz Hi, The following is a very simple test program that consistently causes BoostC16.pic.exe to get an Internal Error. Attempting to compile this program more than once hangs my computer. I'm running XP, SP2. #include <system.h> char myArray[3][4] = {"abc", "def", "ghi"}; void main() { } Help! Regards, Perry
  3. Pavel, Thank you for fixing it so quickly. Regards, Perry
  4. I downloaded the latest 1.9.1 releases and tried to compile the i2c.c sample program in the samples\c\BoostC directory. I get the following output as well as having the original unmodified source file i2c.c deleted by the compiler. (I'm not kidding, the source file gets deleted during the compile!) I've tried this on two different PCs both running XP, one with SP2 the other without the SP2 patch applied. Both PCs did the exact same thing. I've picked the 18F877 as the target CPU. BoostC Optimizing C Compiler Version 1.9.1 Beta (test build) (for PIC16 architecture) http://www.picant.com/c2c/c.html Copyright© 2004-2005 Pavel Baranov Copyright© 2004-2005 David Hobday line 70: Illegal redefinition of symbol: PORTC line 71: Illegal redefinition of symbol: TRISC 2 errors detected Error: preprocessing error success BoostLink Optimizing Linker Version 1.9 Beta http://www.picant.com/c2c/c.html Copyright© 2004-2005 Pavel Baranov Copyright© 2004-2005 David Hobday Error: Failed to open:I2C-Test.obj Warning: Unable to successfully create 'delay_us' for target with clock freq 4000000 Hz Warning: argument of 'delay_10us' calls must have a value of 1 or more Failed Exit code was -1. [No error.] Removing target: I2C-Test.hex File 'C:\Program Files\SourceBoost\Samples\C\BoostC\I2C-Test.c' does not exist. Relevant source window has been closed. File 'C:\Program Files\SourceBoost\Samples\C\BoostC\I2C-Test.c' does not exist. Relevant source window has been closed. File 'C:\Program Files\SourceBoost\Samples\C\BoostC\I2C-Test.c' does not exist. Relevant source window has been closed. File 'C:\Program Files\SourceBoost\Samples\C\BoostC\I2C-Test.c' does not exist. Relevant source window has been closed. File 'C:\Program Files\SourceBoost\Samples\C\BoostC\I2C-Test.c' does not exist. Relevant source window has been closed. Failed to locate output file 'I2C-Test.obj' Done Failed **** There's also a bug in the installer and MPLAB 7.0. Apparently the Legacy directory in the MPLAB tree has been renamed to Third Party. The install complains that it can't copy the mtc files. No biggie, the files can be copied into the correct directory, just a nusance.
  5. Pavel, Yes this does work, however, my ic-prog programmer software has long since "whacked" the osccal value. I presume that there's no way to recover that... Does anyone else know of a "free" programming package that doesn't erase the osccal that works with JDM programers? I don't think the MicroChip software is free... Thank you though! And thank you for writing/supporting such a great development platform! Regards, Perry P.S. Is there a more comprehensive manual that documents the full BoostC product? The help file is good but seems to skip detail in many areas. I'm looking for documentation on things like adding an underscore on a variable name allows it to be referenced in assembler and other goodies like that. I'm learning alot by searching this forum, but I'm sure there's more.
  6. Pavel, Did the OSCCAL feature/fix ever get implemented, I using BoostC 1.8 with a 12F675? I try setting the osccal variable with a value within the code (osccal = 0xfe;) and I still get complaints about OSCCAL not being set from my programmer, ic-prog. I also tried including the bit of assembler asm { call 0x3FF movw osccal, f } but I keep getting an "error in built in assembly" for the movw line. Thanks, Perry
  7. Pavel, I just realized that I downloaded 1.8 but never applied it. Sorry, my mistake! I just unzipped it and now the message is gone. Regards, Perry
  8. I'm a registered IDE 5.7 and BoostC 1.6 user. I recently downloaded the BoostC 1.8 alpha. Now when I compile a program I keep getting warnings about 1.8 alpha expiring in three days (as of today). Will there be a new version or did I hose something up by downloading the 1.8? Thanks!
  9. I registered yesterday and my wizard is grayed out too. However, I do have a template directory, but it's empty. Could someone please zip the contents of their tempate directory and post it? Thanks!
×
×
  • Create New...