This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Problem writing some Ecan registers in a 28069M

Other Parts Discussed in Thread: CONTROLSUITE
I'm trying to initialise the Ecana peripheral in a 28069M and I think I've added all the required code, but one section is not working correctly
    ECanaMboxes.MBOX0.MSGID.all = 0x00040000; //receive standard ID 00000000001
    EcanaRegs.CANME.all = 0; //disable all mailboxes
    EcanaRegs.CANMD.all = 0xFFFFFFFF; //all mailboxes to receive for now
    EcanaRegs.CANME.all = 0x1; //enable mailbox 0
    //ECanaShadow.CANME.all = EcanaRegs.CANME.all;
    //ECanaShadow.CANME.bit.ME0 = 1; //enable mailbox 0
    //EcanaRegs.CANME.all = ECanaShadow.CANME.all;
    asm(" EALLOW");
ECanaRegs.CANMIM.all = 0xFFFFFFFF; //Mailbox interrupt mask register. All 32 rx and tx interrupts enabled
ECanaRegs.CANGIM.all = 0x0000FFFF; //enable global CAN interrupts
    asm(" EDIS");
The first line writes the correct value to the MSGID register OK, but lines 3 and 4 refuse to write to the CANMD and CANME registers. I think CANGIM has the same problem, whilst CAMIM writes ok. 
I tried the example Back2Back program and that works fine writing these registers, so I'm guessing I must be doing something wrong in the sequence of writing them, but I've no idea what.
Can anyone suggest what the problem might be ?
Thanks,
Geoff
  • Could it be that you fail to access the registers 32-bit-wise by not using shadow structures (see section 1.3.2.1 of spru074f.pdf or section 16.3.2.1 of spruh18e.pdf)?

    Regards, Johannes

  • Hi Johannes,

    No I don't think that's the problem.

    I am writing to these registers 32-bits at a a time using a set of registers "EcanaRegs" which have been correctly mapped to the device registers. I know this is the case because I am succeeding in writing to other ecan registers using EcanaRegs.

    It's my understanding that you only need to use shadow registers when you want to change individual bits in a register, i.e. copy EcanaRegs to a shadow register, modify the bit or bits in the shadow, then copy the whole shadow back to the relevant EcanaRegs.

    In addition the EcanaRegs method is the one used in the ControlSuite EcanBack2Back example code, and the exact same regs I'm having a problem with, write successfully in the example.

    It's also been suggested that maybe I needed to use EALLOW to access these two regs because they may be protected, but that doesn't work either and there's no EALLOW done in the example code.

    Thanks anyway,

    Geoff

  • Geoff,

    Trey brought this to my attention and we are working on this. In my experience , almost all write problems in eCAN module can be traced to either EALLOW not being active or the code not performing 32-bit read/writes or the module clock not being enabled. It appears that is not the case here.One observation though: Before writing to the MSGID of a mailbox, the MBX has to be disabled. I notice that you disable *after* you write to MSGID. In any case, since you have confirmed this write goes through, I am assuming some prior code has disabled this MBX.

    Are you able to write directly to the register through CCS, when a write through code fails?

  • Hareesh,

    Yes, I am able to write to these registers from CCS, Trey has my project if you want to try it, and I think he has already checked this.

    I can write to the actual registers in the debug Registers window and the values change correctly. I can also put EcanaRegs in the Expressions window, write values to EcanaRegs and then when I examine the registers in the Registers window, they have changed to the values I wrote to EcanaRegs.

    In addition, this problem does not occur with all the registers, so whilst CANME and CANMD refuse to write correctly from the code in the InitEcana() (whilst writing correctly from the debug windows) , a few lines further down, CANMIM does write correctly from the code.

    Finally, I have used InitEcana() in an almost identical form in the ControlSuite EcanBack2Back example, and CANME, CANMD and all other registers write correctly from the code and the Ecan peripheral works fine. So, pretty well identical code works fine in one project but not another.

    On the MBOX disable point, there is a line disabling all the mailboxes just before I write the MSGID, the other disable, after the MSGID write, sneaked in while I was debugging.

    I hope you can find the answer to this, it seems a real mystery to me, and it's brought my project development to a halt. This system needs canbus and I can't use it.

    Thanks,

    Geoff

  • Hareesh,

    I'm sure you've got lots of other things to do, but it's now two weeks since I raised this problem and my project has ground to a halt ever since.

    Can you let me know whether you will be able to look at this soon, as I really need to get things moving again as soon as possible.

    Regards,

    Geoff

  • Geoff,

    I did look at this and was unable to reproduce this issue. Could you please send the C source file that exhibited this behavior? I do *not* want your entire project. (Trey already provided me that). Just the C source file where you saw this behavior.

  • Hareesh and Trey,

    Canbus is now working fine and reciving data from an external node.

    Sorry that the problem was of my own making with the mistake in naming ECanaRegs as EcanaRegs for the problem registers. My only consolation is that two of you didn't spot the mistake for some time either.

    Thanks very much to all concerned for sorting out this problem.

    Regards,

    Geoff