Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
complied for Pinguino and Pinguino-micro
13-01-2013, 04:06 PM,
#1
complied for Pinguino and Pinguino-micro
OK, I am still messing around with the Pinguino-Micro and not getting very far as my 'C' is limited and majority of documentation is around 'C'

So I have a very simple test application that flashes a green led and if the button is pressed, then lights the yellow led.

If I complie under either pinguino or pinguino-micro, the leds work but there is no definition for USERBUTTON under pinguino-micro.

So I head down into const.h and see that this is missing and simply copy it from the pinguino section :

#define USERBUTTON 2 //PORTDbits.RD0 = user button

The switch is on RD0.

But this still does not work when compiled under pinguino-micro. Whats more, the led definitions are different between micro and pinguino-micro but both work. I even removed GREENLED and compiled to make sure it errored (which it did), so I know that file is being used.

#elif defined (PIC32_PINGUINO_MICRO)
#define GREENLED 32 //PORTGbits.RG6 // led1
#define YELLOWLED 10 //PORTDbits.RD1 //

#elif defined(PIC32_PINGUINO) || defined(PIC32_PINGUINO_OTG)
// OLIMEX build-in leds
#define GREENLED 13 //PORTGbits.RG6 // led1
#define YELLOWLED 30 //PORTDbits.RD1 // led2

-------------------------

So here's my simple code, could anyone please explain why it compiles and the leds work under the two different definitions and why adding the USERBUTTON in does not work..... Thanks in advance

-------------------------

void setup() {

// put your setup code here, to run once:

pinMode(YELLOWLED, OUTPUT);
pinMode(GREENLED, OUTPUT);
pinMode(USERBUTTON, INPUT);

}

void loop() {

//detect if the button is pressed and show the result on the yellow led
if (digitalRead(USERBUTTON))
digitalWrite(YELLOWLED,LOW);
else
digitalWrite(YELLOWLED,HIGH);

//flash the green led in the loop just to prove something is going on !
digitalWrite(GREENLED,HIGH);
delay(200);
digitalWrite(GREENLED,LOW);
delay(100);

}

-------------------------
Reply
13-01-2013, 09:48 PM,
#2
RE: complied for Pinguino and Pinguino-micro
OK, finally figured it out after stumbling on a post from 'regis' http://forum.pinguino.cc/showthread.php?tid=3612 showing how the portmask and the pinmask work. For anyone new to PIC32MX / Arduino and trying to figure it out :

Quote:if LED1 is on pin #37 = MCU pin#30 = RB15, then you should have this in digitalw.c :
portmask[37]=pB
pinmask[37]=_15


The portmask and pinmask show in an array like
Quote:#ifdef PIC32_PINGUINO_MICRO

const u32 portmask[]= {pB,pB,pB,pB,pB,pB,pB,pB, // 0-7
pB,pB,pD,pD,pD,pD,pD,pD, // 8-15
pB,pD,pD,pD,pG,pF,pE,pE, // 16-23
pE,pE,pE,pE,pE,pE,pC,pC, // 24-31
pG,pF,pF,pD,pD,pG,pG,pF, // 32-39
pB,pD}; // 40-41 P41 strapped with P13

const u32 pinmask[]= {_1,_2,_3,_4,_8,_9,_10,_11, // 0-7
_12,_14,_1,_2,_3,_4,_5,_6, // 8-15
_0,_7,_8,_11,_9,_1,_7,_6, // 16-23
_5,_4,_3,_2,_1,_0,_13,_14, // 24-31
_6,_4,_5,_9,_10,_8,_7,_0, // 32-39
_13,_0}; // 40-41 P41 strapped with P13
#endif

-------------------

Conclusion
The maps for pinguino and pinguino-micro happen to show RD1 and RG6 at the same point hence why it works, but USERBUTTON (RD0 P41) was not defined.

so long and the short of it.......

add to const.h in section : #elif defined (PIC32_PINGUINO_MICRO)

#define USERBUTTON 41 //PORTDbits.RD0 = user button

Big Grin
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)