Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
i2c/wire does not compile for pic18f45k50
04-10-2014, 07:58 PM, (This post was last modified: 04-10-2014, 08:03 PM by GastonLagaffe.)
#1
i2c/wire does not compile for pic18f45k50
Salut,
I am pretty new to pinguino, got me the PIC18F45k50 board. So far all works fine.
When trying the master.pde example, it compiles with the PIC18F4550 board selected but gives error when selecting the PIC18F45k50 board. The two errors are:
Code:
Undefined identifier 'SSPCON1'
'_R_W' not a structure/union member

Before diving into the pinguino source code: is there a simple fix available? The error lines refer to number way beyond the pde numbers. Where can I find the source to which the errors refer?

Ciao, Mathias
Pinguino 10.4, Windows7, PIC18F45k50 kit from shop
Reply
04-10-2014, 08:13 PM,
#2
RE: i2c/wire does not compile for pic18f45k50
(04-10-2014, 07:58 PM)GastonLagaffe Wrote: Salut,
When I created this application the 18f45k50 board did not exist. I try ASAP to add the possibility of using this chip.
I shall attach the new files.
Bye
André
Reply
04-10-2014, 09:19 PM, (This post was last modified: 04-10-2014, 09:57 PM by gtcbreizh.)
#3
RE: i2c/wire does not compile for pic18f45k50
(04-10-2014, 08:13 PM)gtcbreizh Wrote:
(04-10-2014, 07:58 PM)GastonLagaffe Wrote: Salut,
When I created this application the 18f45k50 board did not exist. I try ASAP to add the possibility of using this chip.
I shall attach the new files.
Bye
André

Here attached i2c.c to replace the same file in folder x.4\p8\pinguino\core\

If you had worked with IDE v11 you would not get error in compiling master.pde because i2c.c was already corrected to be used with the 18f45k50.
Have fun with i2c master and slave communication !
André

P.S.: I have to revise i2cslave.c too. I do it ASAP.


Attached Files
.c   i2c.c (Size: 22.71 KB / Downloads: 5)
Reply
05-10-2014, 12:12 AM,
#4
RE: i2c/wire does not compile for pic18f45k50
Salut André,

pretty impressive response time! With the new i2c.c file it compiles ...

I come from the arduino world and try to find my way with pinguino. I tried the 11.x version but failed using it with the Olimex pinguino. I was told to revert back to the 10.4 version which worked so I started with 10.4 for the original boards (I have the PIC18F45K50 and the PIC32MX250 board from the shop)
I will try 11.x for these now

Thanks for the superb support that late in the night.
Ciao, Mathias
Reply
05-10-2014, 12:48 AM, (This post was last modified: 05-10-2014, 01:00 AM by GastonLagaffe.)
#5
RE: i2c/wire does not compile for pic18f45k50
Salut André,

I tried the 11.x IDE. There is a typo in digital.h: 142 - there is a comma missing at the end of the line. I tried to compile the blink.pde example. It compiles ok, loads ok but the USERLED does not blink. When I try the blink example in 10.4, the led blinks (and I made sure I am seeing the change by varying the blink period).
When I use the example using the PIC registers, the LED blinks. Looks like the pin mapping for the 45k50 is wrong. I found the right number to be 12 instead of the 29 I found in the pin.h file, line 408.

I am pretty good in testing and I like the pinguino board, so I will continue to test all examples. Looks like fun ..

Ciao, Mathias
Reply
05-10-2014, 09:15 AM,
#6
RE: i2c/wire does not compile for pic18f45k50
Salut Mathias,
I tested the Blink.pde on an original old 40 pins pinguino board equipped with a 18f45k50 instead of a 18f4550. The blinking led is connected to RA4 as it is on the new 18f45k50 kit. I suppose this kit is your board ?
I let USERLED as #pin. It worked.
I put 29 as #pin. It worked.
I put 12 as #pin. Nothing happened.
Could you check the user led is really connected to RA4 (chip pin #6) ?
Bye
André
Reply
05-10-2014, 11:05 AM,
#7
RE: i2c/wire does not compile for pic18f45k50
(05-10-2014, 09:15 AM)gtcbreizh Wrote: Salut André,

I checked the board and everything looks ok as on the schematics: Pin6 -> R(470Ohm) -> Led -> GND
I am using this code:


Code:
int led=29;
void setup()
{
   pinMode(led, OUTPUT);    
}

void loop()
{
/**/
   toggle(led);            // alternate ON and OFF
   delay(200);              // wait for 500ms
   toggle(led);            // alternate ON and OFF
   delay(200);              // wait for 500ms
   toggle(led);            // alternate ON and OFF
   delay(100);              // wait for 500ms
   toggle(led);            // alternate ON and OFF
   delay(100);              // wait for 500ms
   toggle(led);            // alternate ON and OFF
   delay(300);              // wait for 500ms
   toggle(led);            // alternate ON and OFF
   delay(300);              // wait for 500ms
}
and the led is OFF. Same with USERLED. Switching to


Code:
int led=12;
and the led is working. Using


Code:
void setup()
{
   TRISAbits.TRISA4 = OUTPUT;
}

void loop()
{
   LATAbits.LATA4 = LOW;
   delay(50);
   LATAbits.LATA4 = HIGH;
   delay(500);
}
and the led is blinking.
In my eyes, the hardware is ok.
I have done a clean install of IDE 11.x freshly downloaded from the pinguino.cc site. I also had to replace the i2c.c with the file you provided to get the master.pde file to compile.
Very weird ...

Ciao, Mathias
Reply
05-10-2014, 12:20 PM, (This post was last modified: 05-10-2014, 12:43 PM by gtcbreizh.)
#8
RE: i2c/wire does not compile for pic18f45k50
I worked with X.4
I changed into V11 and now I observe with led=29 the led stay On, with led=12 it blinks, with USERLED too.
So there is something wrong or changed with the lib V11. I have a look.

In fact in the new pin.h USERLED is defined as pin #12
/**********************************************************************/

    #elif defined(PINGUINO45K50)
/**********************************************************************/
    
        #define A4          12
        //#define RA4       29
        #define RUNLED      12
        #define LED1        12
        #define USERLED     12
        #define CCP1        18  // RC2
        #define CCP2        17  // RC1

Furthermore the pin numbering is :
 0-7 for RB0-RB7
8-15 for RA0-RA7
16-23 for RC0-RC7
24-31 for RD0-RD7
32-35 for RE0-RE3
therefore very very different from the 18f4550 !

Everything is ok/logical but the wiki relating to 18f45k50 is not updated !!!
Bye
André
Reply
13-10-2014, 04:38 PM, (This post was last modified: 14-10-2014, 10:00 AM by GastonLagaffe.)
#9
RE: i2c/wire does not compile for pic18f45k50
Salut André,

I created a pinmap for the PIC18F45K50. I hope, I made no mistakes ...

Ciao, Mathias
[Update] attachement updated to fix the errors reported below[/Update]


Attached Files Thumbnail(s)
   
Reply
13-10-2014, 09:51 PM, (This post was last modified: 13-10-2014, 10:31 PM by gtcbreizh.)
#10
RE: i2c/wire does not compile for pic18f45k50
Salut Mathias,
Nice job! Anyway some pins to change :
RA5 (pin 7 /chip) is only #13 pinguino, not #18
RA6 is #14, not #15
RA7 is #15, not #14
RC2 (pin 17/chip) #18 is missing, see above RA5 ?
RE0-1-2 (pins 8-9-10/chip) #32-33-34 are available as AN5-6-7
D- D+ (pins 23-24/chip) are #20/21 usable without USB connecting
MOSI can be on RC7 depending on configuration bits (see datasheet)

Good luck
Bye
André
PS : Really it is not difficult to put examples on the Wiki. You must start  with the help pages!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)