CAN Information request message MCP25050

21 Mar 2011

Hi,

Just a quick question, I'm trying to read the A/D regs on the MCP25050. To do this I need to send a IRM with ID 0, DLC 8 and no data. But the CAN message for the NXP wont let me put "no data" in the message. I've tried zeros and FF etc.

Any ideas?

Awstriker

21 Mar 2011

Ahh CANRemote...

Now to conquer Extended...

23 Mar 2011

CANRemote? I've been using: CANMessage(int _id, CANFormat _format = CANStandard), which wreates CAN remote message. Just because I'm not 100% sure if sending a normal CANMessage with type=1 and length=0 will do the same.

23 Mar 2011

As far as i'm aware the 11bit Id doesn't include the DLC so when using an Information Request message the IO expander doesn't know what to send back.

Using CANRemote eg,

can2.write(CANMessage(0,0,8,CANRemote,CANStandard))

This broadcasts a READ A/D REGS information request message aimed at the I/O expanders. This works and the expanders return their data but they are all returned with ID 0 as that is what was sent. If you put an destination ID for the Expanders to filter, the message is no longer valid and the expanders do not respond.

Then BREAKTHROUGH... whilst writing this I realised I had to set bit 3 of the IRM ID =1 and the masks on my chips where comparing this bit and therefore the filters were ignoring the message. So...

CANMessage(648,test,8,CANRemote,CANStandard)) where 648 (288 in hex) is its ID + bit 3 set + the message type your requesting (0 for READ A/D). test can be 0 but there needs to be something in there, 8 is the DLC for READ A/D, and the rest is self explanatory.

Thanks for the reply otherwise I wouldn't of looked at this again :)

Awstriker

24 Mar 2011

I've been using CAN-open which uses a predefined connection set. So the ID's are a bit different. I've been using the following code to send my PC messages through CAN:

    if(pc_type==0) { // Normal Message
        if(can1.write(CANMessage(pc_ID,candata,(char)pc_length,pc_type,pc_format))) {
            pc.printf("MBED:    [ Message compiled and sent. ]\n");
            write_activity = !write_activity;
        }
    }
    else if(pc_type==1) { // RTR
        if(can1.write(CANMessage(pc_ID,pc_format))) {
            pc.printf("MBED:    [ RTR Message compiled and sent. ]\n");
            write_activity = !write_activity;
        }
    }

In CANopen, as long as your device is mapped and configured correctly, and the RTR is sent to the right ID, you should get the right data. I've not worked with the base CAN protocol allot tho, it's a bit different.

But atleast you seemed to have figured it out :)

Melchior