7 years, 7 months ago.

Switch Matrix LPC1549 Xpresso board

I have just started to use the LPC1549 Xpresso board

and I want to re-map the serial port, as well as CAN to OTHER pins,

I have attempted to declare them to other pins, but no effect.

Am I missing something ??

Cheers

Ceri.

Hi, Can I see your code?

posted by Toyomasa Watarai 09 Apr 2017

Just now: I told CAN to be on D6, D7, and it works :)

Last week, the problem arose because D5 & D13 are shorted together !!!

HOW STUPID !!

I spent SO much time on fixing a non existent problem !!.

Additionaly, I have assigned serial to 'other' pins, as well as TWO seperate serial ports.

although not yet tested id SD Memory card works.

Anyway .. for those interested, this is my (very messy) code.

Start


/*
#include "mbed.h"

#define TD P0_18
#define RD P0_13

#define testRX P0_14
#define testTX P0_15

CAN can1 (TD,RD);
//Serial uart0(testTX,testRX);
Serial pc (P0_0, P1_3);
*/

#include "mbed.h"

#define TD P0_31 // P0_18
#define RD P0_11 // P0_13

#define testRX P0_14
#define testTX P0_15

enum RGB
{
    R, G, B
};

CAN can1 (D6, D7);  // (TD,RD);
//Serial uart0(testTX,testRX);
Serial pc (P0_18, P0_13); // (P0_0, P1_3);
PwmOut led_R (LED_RED);
PwmOut led_G (LED_GREEN);
PwmOut led_B (LED_BLUE);


// Warning D5 & D13 phisicaly connected together !!!!

//SPI spi_A (D11, D12, D13);  //  (P0_28, P0_12, P0_16);  // 
//SPI spi_B (D4,  D6,  D7); // (D5,  D6,  D7);

// no SPI spi2 (p5, p6, p7);    //SIN (p6), SCLK,GSCLK(p7)

CANMessage msg;

bool GotMessage;
int CanCount;

char canmESSAGE[] = "722 3 76 ad 23 2f 99 bb cc aa";
char MessTemp [32];



char packet [8];


Timer t;
Timer TimeStamp;

char * pEnd;
int CA, CL;
char CD[8];

void SerialINT()
{
    // Note: you need to actually read from the serial to clear the RX interrupt
    //printf("%c\n", pc.getc());

    char c = pc.getc();

    if (c == '\n') return;

    if (c == '\r') {
        // end of message ??
        //canmESSAGE.copy (MessTemp, 32,0);
        for (int c = 0; c <32; c ++) {
            // copy AND Destroy ..
            canmESSAGE[c] = MessTemp [c];
            MessTemp[c] = 0;
        }

        CanCount = 0;
        //led2 = !led2;
        GotMessage = true;
    } else {
        MessTemp [CanCount++] = c;

    }
}


char MyString [32] = "0x4d2";
int ans;


void     decode_message (void);
void Build_Message (int L);

void Pulse_LED (int RGB, int T_On, int T_Off);



int main()
{

    pc.baud(115200);
    can1.frequency(500000); // 50kbit i-can  50K, 100K 125K 250K
    //pc.baud(9600);


    // test spi port ..
    
    //SPI_Port.write (0x99);
    
//-    spi_A.format(12,0);
//-    spi_A.frequency(3000);

 //-   int whoami_A = spi_A.write(0);

//-    spi_B.format(12,0);
//-    spi_B.frequency(5000);

 //-   int whoami_B = spi_B.write(0);

    pc.attach(&SerialINT);

    TimeStamp.start();

    led_R = 1; // -> off
    led_G = 1; // -> off
    led_B = 1; // -> off
    







posted by ceri clatworthy 10 Apr 2017
Be the first to answer this question.