Thread Rating:
  • 2 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
MPLabX & Pinguino without X3 IDE
30-12-2012, 04:38 PM,
#11
RE: MPLabX & Pinguino without X3 IDE
I'm amazed how stunningly successful Oberon has been and you find it everywhere, don't you?

You'll be happier with the ICSP perhaps. Then put Oberon on the boards Smile

John
Reply
10-01-2013, 10:36 PM,
#12
RE: MPLabX & Pinguino without X3 IDE
Not Niklaus Wirth's finest hour ? - By coincidence, (why the mention of Oberon??), for several years I worked on it's predecessor - writing Modula-2 compilers (on M68000 family - Amiga, Atari ST and Pinnacle Unix boxes - I even got a compiler working on the Sinclair QL though that was just for fun) but the language is pretty much lost to history now.....

A brief progress report - after the stress that is Christmas (at work rather than the event) - I have succeeded, to a degree, getting MPLab to work with my Pinguino.

So the microcontroller equivalent of HelloWorld - blink is up and running using the Pinguino libraries compiled in MPLabX.

The bad news - my first attempt rendered my Pinguino-OTG dead, not sure why though - just downloading a program to it stopped halfway through the download and after that it was no go.

So with a cheap PicKit 3 (I had to go for a cheap Chinese clone for financial reasons) and an Olimex ICSP adapter - I tried again. Success! First attempt once I realised the Pinguino had to be powered seperately (AVR & ICSP didn't - so I'd just assumed here)

So if anyone is interested (and there have been a couple of other posts on this topic) - I can share details of the steps so far.
I haven't tried further than blink so far (PicKit arrived today!) - and I'll probably have to worry about reinstalling the bootloader next - and if anyone knows how to get the output from MPLab to be compatible with the standard bootloader then it would save some work.

Of course - it is probably easier to use a PicKit and ICSP transfers (it is quick and easy) - but not everyone has access to this facility.

Martin


(30-12-2012, 04:38 PM)pingotg Wrote: I'm amazed how stunningly successful Oberon has been and you find it everywhere, don't you?

You'll be happier with the ICSP perhaps. Then put Oberon on the boards Smile

John
Reply
11-01-2013, 05:54 PM,
#13
RE: MPLabX & Pinguino without X3 IDE
Stranger things have happened - see Dmitry Grinberg's amazing (if rather impractical) work getting Linux running on an 8 bit microcontroller.

http://dmitry.co/index.php?p=./04.Though...0on%208bit

(30-12-2012, 04:38 PM)pingotg Wrote: I'm amazed how stunningly successful Oberon has been and you find it everywhere, don't you?

You'll be happier with the ICSP perhaps. Then put Oberon on the boards Smile

John
Reply
11-01-2013, 06:32 PM,
#14
RE: MPLabX & Pinguino without X3 IDE
Wow.

John
Reply
03-09-2013, 12:28 AM,
#15
RE: MPLabX & Pinguino without X3 IDE
When using C we don't have to 're-write everything'.

We can just use header files and functions already written.

Pinguino is a very handy hardware platform.

We want to build our application in C in MPLAB, with a configuration header file for PINGUINO, that builds a hex compatible with the BOOTLOADER.

We want to then download it to the PINGUINO board over USB.

Please understand that C is the best tool to use.

In particular I would like to use the advanced and awesome pulse capture capability of the pic32, and the wealth of C examples to do this. As well as utilize my experience in the most popular embedded programming language in the word: 'C'

There is no advantage learning some web-scripting language to do embedded development.

However I would love to have a ready made C source file that allows use of the bootloader and configuration of Pinguino.

The combination of above scenarios, allows the flexibility of power of C, without having to scratch around at the lowest level and work out how to do everything from the beginning.

Also, it is important to fully understand that C experience is not necessarily Microchip PIC32 experience. They are two different fields of knowledge. That is why it is good to provide ready-made headers and source files that do all the setup and configuration relevant to the Pinguino board.

If this isn't already done, I will do it and share.
Reply
07-04-2017, 06:15 PM,
#16
RE: MPLabX & Pinguino without X3 IDE
To warm up an old thread:

I try to use MPLABX for a PIC32-PINGUINO-MX220 project. To start, I made a simple LED "ladder" with LEDs connected to all digital ports.
When switching them on and off with a simple Pinguino IDE program, all works fine.
But with a MPLABX compiled firmware, only a few switch on, and none switches off again.

I use the following configuration, that I collected in various Pinguino IDE soruces:

void configIO(void) {
// from Pinguino IDE main32.c & io.c
// IOsetDigital();
#if defined(32MX220F032D)||defined(32MX250F128B)||defined(32MX220F032B)
CFGCONbits.JTAGEN=0; // Disable the JTAG port, Port A as Digital Port
ANSELA = 0;
ANSELB = 0;
#if defined(32MX220F032D)
ANSELC = 0;
#endif
#else
DDPCONbits.JTAGEN=0; // Disable the JTAG port, Port A as Digital Port
AD1PCFG = 0xFFFF;
#endif

// IOsetSpecial();
TRISA = 0;
TRISB = 0;

#if !defined(__32MX250F128B__) && !defined(__32MX220F032B__)
TRISC = 0;
#if !defined(__32MX220F032D__)
TRISD = 0;
TRISE = 0;
TRISF = 0;
TRISG = 0;
#endif
#endif

#if defined(PIC32_PINGUINO) || defined(PIC32_PINGUINO_OTG)
TRISDbits.TRISD9 = INPUT; // because PORTB is shared with SDA on Olimex board
TRISDbits.TRISD10 = INPUT; // because PORTB is shared with SCL on Olimex board
#endif


// IOsetRemap();
#if defined(PIC32_PINGUINO_220)
SystemUnlock();
CFGCONbits.IOLOCK=0; // unlock configuration
CFGCONbits.PMDLOCK=0;
#ifdef __SERIAL__
U2RXRbits.U2RXR=6; // Define U2RX as RC8 ( D0 )
RPC9Rbits.RPC9R=2; // Define U2TX as RC9 ( D1 )
U1RXRbits.U1RXR=2; // Define U1RX as RA4 ( UEXT SERIAL )
RPB4Rbits.RPB4R=1; // Define U1TX as RB4 ( UEXT SERIAL )
#endif
#ifdef __SPI__
SDI1Rbits.SDI1R=5; // Define SDI1 as RA8 ( UEXT SPI )
RPA9Rbits.RPA9R=3; // Define SDO1 as RA9 ( UEXT SPI )
#endif
#ifdef __PWM__
RPC2Rbits.RPC2R =0b0101; // PWM0 = OC3 as D2 = RC2
RPC3Rbits.RPC3R =0b0101; // PWM1 = OC4 as D3 = RC3
RPB5Rbits.RPB5R =0b0101; // PWM2 = OC2 as D11 = RB5
RPB13Rbits.RPB13R=0b0110; // PWM3 = OC5 as D12 = RB13
RPB15Rbits.RPB15R=0b0101; // PWM4 = OC1 as D13 = RB15
#endif
CFGCONbits.IOLOCK=1; // relock configuration
CFGCONbits.PMDLOCK=1;
SystemLock();
#endif

// Thanks to danirobin
// what version is now correct??
#if defined(PINGUINO32MX250) || defined(PINGUINO32MX220)
SystemUnlock();
CFGCONbits.IOLOCK=0; // unlock configuration
CFGCONbits.PMDLOCK=0;
#ifdef __SERIAL__
U2RXRbits.U2RXR =0b0010; // Define U2RX as RB1
RPB0Rbits.RPB0R =0b0010; // Define U2TX as RB0 _
U1RXRbits.U1RXR =0b0100; // Define U1RX as RB2 ( D10 )
RPB3Rbits.RPB3R =0b0001; // Define U1TX as RB3 ( D9 )
#endif
#ifdef __SPI__
SDI1Rbits.SDI1R=1; // Define SDI1 as RB5 [Overlap!]
RPA4Rbits.RPA4R=3; // Define SDO1 as RA4 [Overlap!]
#endif
#ifdef __PWM__
RPB4Rbits.RPB4R =0b0101; // PWM0 = OC1 = RB4
RPA4Rbits.RPA4R =0b0110; // PWM1 = OC4 = RA4
RPB5Rbits.RPB5R =0b0101; // PWM2 = OC2 = RB5
RPB13Rbits.RPB13R=0b0101; // PWM3 = OC5 = RB13
RPB14Rbits.RPB14R=0b0101; // PWM4 = OC3 = RB14
#endif
CFGCONbits.IOLOCK=1; // relock configuration
CFGCONbits.PMDLOCK=1;
SystemLock();
#endif


Any hints?
Reply
10-04-2017, 02:37 PM,
#17
RE: MPLabX & Pinguino without X3 IDE
I'd like to see the whole program to help you.

Meanwhile, if your board is an Olimex one, your configIO() routine should only care about those #define :
__32MX220F032D__ (the proc.) and PIC32_PINGUINO_220 (the board) but not 32MX220F032D.
FYI, PINGUINO32MX220 refers to another board.

The following line should then not work :

#if defined(32MX220F032D)||defined(32MX250F128B)||defined(32MX220F032B)
CFGCONbits.JTAGEN=0; // Disable the JTAG port, Port A as Digital Port
ANSELA = 0;
ANSELB = 0;
...

And this is probably the reason why your LED does not blink.
It is easier to complain than it is to do, but it is better to do than it is to complain.
Reply
23-04-2017, 05:10 PM,
#18
RE: MPLabX & Pinguino without X3 IDE
Here it is, collected from different source files:

#ifdef PIC32_PINGUINO_220
#define D0 PORTCbits.RC8 // UART2_RX
#define D1 PORTCbits.RC9 // UART2_TX
#define D2 PORTCbits.RC2 // PWM
#define D3 PORTCbits.RC3 // PWM
#define D4 PORTCbits.RC4
#define D5 PORTCbits.RC5
#define D6 PORTCbits.RC6
#define D7 PORTCbits.RC7
#define D8 PORTBbits.RB7 // USERBUTTON, if AREF_E closed provides AREF!
#define D9 PORTAbits.RA10 // LED2 (red)
#define D10 PORTAbits.RA1 // if D10_E open, disconnected! (PGEC3)
#define D11 PORTBbits.RB5 // PWM, SPI2 MOSI
#define D12 PORTBbits.RB13 // PWM, SPI2 MISO
#define D13 PORTBbits.RB15 // PWM, LED1 (green), SPI2 CLK (SCK2)
#define D20 PORTAbits.RA7 // UEXT_CS
#define D21 PORTBbits.RB8 // UEXT_SDA1
#define D22 PORTBbits.RB9 // UEXT_SCL1
#define A0 PORTCbits.RC0
#define A1 PORTCbits.RC1
#define A2 PORTBbits.RB0
#define A3 PORTBbits.RB1
#define A4 PORTBbits.RB2
#define A5 PORTBbits.RB3 // SCL2, RTCC
#define D0_DIR TRISCbits.TRISC8 // UART
#define D1_DIR TRISCbits.TRISC9 // UART
#define D2_DIR TRISCbits.TRISC2 // PWM
#define D3_DIR TRISCbits.TRISC3 // PWM
#define D4_DIR TRISCbits.TRISC4
#define D5_DIR TRISCbits.TRISC5
#define D6_DIR TRISCbits.TRISC6
#define D7_DIR TRISCbits.TRISC7
#define D8_DIR TRISBbits.TRISB7 // USERBUTTON, if AREF_E closed provides AREF!
#define D9_DIR TRISAbits.TRISA10 // LED2 (red)
#define D10_DIR TRISAbits.TRISA1 // if D10_E open, disconnected! (PGEC3)
#define D11_DIR TRISBbits.TRISB5 // PWM, SPI2 MOSI
#define D12_DIR TRISBbits.TRISB13 // PWM, SPI2 MISO
#define D13_DIR TRISBbits.TRISB15 // PWM, LED1 (green), SPI2 CLK (SCK2)
#define D20_DIR TRISAbits.TRISA7 // UEXT_CS
#define D21_DIR TRISBbits.TRISB8 // UEXT_SDA1
#define D22_DIR TRISBbits.TRISB9 // UEXT_SCL1
#define A0_DIR TRISCbits.TRISC0
#define A1_DIR TRISCbits.TRISC1
#define A2_DIR TRISBbits.TRISB0
#define A3_DIR TRISBbits.TRISB1
#define A4_DIR TRISBbits.TRISB2
#define A5_DIR TRISBbits.TRISB3

#define LED1 D13 // green
#define LED1_DIR D13_DIR
#define LED2 D9 // red
#define LED2_DIR D9_DIR
#define SPI2_MOSI D11
#define SPI2_MOSI_DIR D11_DIR
#define SPI2_MISO D12
#define SPI2_MISO_DIR D12_DIR
#define SPI2_CLK D13
#define SPI2_CLK_DIR D13_DIR
#define UART2_RX D0
#define UART2_RX_DIR D0_DIR
#define UART2_TX D1
#define UART2_TX_DIR D1_DIR
#define USERBUTTON D8
#endif // PIC32_PINGUINO_220


volatile uint8_t counter = 0;
bool setup(void) {

configIO();
// not 0 nor 1 changes something: U2MODEbits.ON = 1;
LED1_DIR = OUT; LED1 = LOW; // set USERLED as output (D13))
LED2_DIR = OUT; LED2 = HIGH; // set red led as output (D9)

D0_DIR = OUT; D0 = LOW;
D1_DIR = OUT; D1 = LOW;
D2_DIR = OUT; D2 = LOW;
D3_DIR = OUT; D3 = LOW;
D4_DIR = OUT; D4 = LOW;
D5_DIR = OUT; D5 = LOW;
D6_DIR = OUT; D6 = LOW;
D7_DIR = OUT; D7 = LOW;
D10_DIR = OUT; D10 = LOW;
D11_DIR = OUT; D11 = LOW;
D12_DIR = OUT; D12 = LOW;

initDelay(SYS_FREQ);
}

bool loop(void) {
switch (counter) {
case 0: D13 = LOW; D0 = HIGH; break;
case 1: D0 = LOW; D1 = HIGH; break;
case 2: D1 = LOW; D2 = HIGH; break;
case 3: D2 = LOW; D3 = HIGH; break;
case 4: D3 = LOW; D4 = HIGH; break;
case 5: D4 = LOW; D5 = HIGH; break;
case 6: D5 = LOW; D6 = HIGH; break;
case 7: D6 = LOW; D7 = HIGH; break;
case 9: D7 = LOW; D9 = HIGH; break;
case 10: D9 = LOW; D10 = HIGH; break;
case 11: D10 = LOW; D11 = HIGH; break;
case 12: D11 = LOW; D12 = HIGH; break;
case 13: D12 = LOW; D13 = HIGH; break;
}

delayS(2);
++counter;
if (counter == 8)
counter++;
if (counter > 13)
counter = 0;
}

int32_t main(void) {
setup();
while (true)
loop();
}


initDelay() and delayS() work, so I have omitted them here.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)