Thread Rating:
  • 2 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
MPLabX & Pinguino without X3 IDE
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


Messages In This Thread
MPLabX & Pinguino without X3 IDE - by mnfisher - 16-12-2012, 12:31 AM
RE: MPLabX & Pinguino without X3 IDE - by pingotg - 16-12-2012, 11:54 AM
RE: MPLabX & Pinguino without X3 IDE - by pingotg - 16-12-2012, 07:16 PM
RE: MPLabX & Pinguino without X3 IDE - by pingotg - 16-12-2012, 09:47 PM
RE: MPLabX & Pinguino without X3 IDE - by pingotg - 17-12-2012, 01:15 AM
RE: MPLabX & Pinguino without X3 IDE - by pingotg - 17-12-2012, 01:49 PM
RE: MPLabX & Pinguino without X3 IDE - by pingotg - 30-12-2012, 04:38 PM
RE: MPLabX & Pinguino without X3 IDE - by pingotg - 11-01-2013, 06:32 PM
RE: MPLabX & Pinguino without X3 IDE - by regis - 10-04-2017, 02:37 PM
RE: MPLabX & Pinguino without X3 IDE - by grindcore - 23-04-2017, 05:10 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)