Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
GCC vs SDCC (about #define and digitalw.c)
05-04-2014, 03:24 PM,
#1
GCC vs SDCC (about #define and digitalw.c)
Hi,
I face a little issue I haven't been able to solve.
If I connect leds and their resistors to pins 0 to 7, why the following lines lead to 8 leds ON (expected result) with SDCC and not with GCC-MIPS-ELF ?

Code:
#define NOKIA_RST     0
#define NOKIA_SCE     1
#define NOKIA_DC      2
#define NOKIA_SDIN    3
#define NOKIA_SCLK    4
#define NOKIA_VCC     5
#define NOKIA_LIGHT   6        
#define NOKIA_GND     7

void setup()
{
    pinMode(NOKIA_RST,   OUTPUT);
    pinMode(NOKIA_SCE,   OUTPUT);
    pinMode(NOKIA_DC,    OUTPUT);
    pinMode(NOKIA_SDIN,  OUTPUT);
    pinMode(NOKIA_SCLK,  OUTPUT);
    pinMode(NOKIA_VCC,   OUTPUT);
    pinMode(NOKIA_LIGHT, OUTPUT);
    pinMode(NOKIA_GND,   OUTPUT);
    
    digitalWrite(NOKIA_RST,   HIGH);
    digitalWrite(NOKIA_SCE,   HIGH);
    digitalWrite(NOKIA_DC,    HIGH);
    digitalWrite(NOKIA_SDIN,  HIGH);
    digitalWrite(NOKIA_SCLK,  HIGH);
    digitalWrite(NOKIA_VCC,   HIGH);
    digitalWrite(NOKIA_LIGHT, HIGH);
    digitalWrite(NOKIA_GND,   HIGH);
}

void loop()
{
}
It is easier to complain than it is to do, but it is better to do than it is to complain.
Reply
05-04-2014, 04:36 PM,
#2
RE: GCC vs SDCC (about #define and digitalw.c)
Do you mean the MIPS case is on a PIC32?

If so, which exact CPU?

I suppose it would be some setup code somewhere, maybe leaving the port set as analog or maybe PPS or who knows?

I take it that the pre-processed file (the .c file) looks OK?

John
Reply
05-04-2014, 05:35 PM,
#3
RE: GCC vs SDCC (about #define and digitalw.c)
I forgot to mention the problem occurs only with PIC32MX2xx family.
If I program something like :
Code:
u8 i;
for (i=0; i<8;i++)
{
pinMode(i,OUTPUT);
digitalWrite(i, HIGH);
}
everything is ok. It's only when I use some #define that it doesn't work at least not for every pin.
I tried to compile with and without MIPS16 option. Nothing change, #define doesn't work.
It is easier to complain than it is to do, but it is better to do than it is to complain.
Reply
05-04-2014, 05:54 PM,
#4
RE: GCC vs SDCC (about #define and digitalw.c)
Is it because the IDE messes around with the order?

The .c file it creates should help, if so.

If it's only the MX2 then I suppose it's not that. It also isn't gcc as it doesn't change what it does with #define just because MX2 is used.

Maybe for testing try replacing all the #define by int, like
int NOKIA_DC = 2;

wasteful but OK for testing.

John
Reply
05-04-2014, 06:17 PM,
#5
RE: GCC vs SDCC (about #define and digitalw.c)
The .c is ok and I already replaced #define with int but I've got the same result.
Quite strange, isn't it ?

(05-04-2014, 05:54 PM)pingotg Wrote: Is it because the IDE messes around with the order?

The .c file it creates should help, if so.

If it's only the MX2 then I suppose it's not that. It also isn't gcc as it doesn't change what it does with #define just because MX2 is used.

Maybe for testing try replacing all the #define by int, like
int NOKIA_DC = 2;

wasteful but OK for testing.

John
It is easier to complain than it is to do, but it is better to do than it is to complain.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)