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.

TMS320F28P650DH: Why freopen function will affect MCAN normally init and MCAN can not run?

Part Number: TMS320F28P650DH
Other Parts Discussed in Thread: C2000WARE, SYSCONFIG

Tool/software:

Hi Experts,

I am asking for my customer here.

This function  init_STDOUT_AND_STDIN() placed before while(1), CPU will only run init code one time, If the customer comments the code in the red box, such as the freopen function, the MCAN can run normally. If the customer adds these codes, the MCAN will run abnormally and enter the Bus off state. and then Check the register MCAN_CCCR_INIT register abnormality and then turn to 1. Do you have any suggestion/Dir? Thanks.

  • Hello Shaoxing,

    What is the requirement for using the freopen() function?

    What is the expectation of the STDOUT_AND_STDIN function?

    There is nothing obvious from the code snippet you shared that leads me to believe it would impact the MCAN module in anyway.

    Can you provide screenshots of the CAN_H/CAN_L signals when then the failure happens and enters the Buss Off state?

    Best Regards,

    Zackary Fleenor

  • Hi Fleenor,

    They are referenced the below example for SCI/UART print and scanf function here. Meanwhile, we add the below freopen function during MCAN example, it also will affect the MCAN normally init and can not work here. 

    C:\ti\c2000\C2000Ware_5_04_00_00\driverlib\f28p65x\examples\c28x\sci\sci_ex4_stdout_redirect example.

  • Hello Shaoxing,

    Where/when are they calling the function that causes the failure and where/when are they doing the CAN initialization?

    Best Regards,

    Zackary Fleenor

  • Hi Fleenor,

    We have reproduced this issue based on our F28P65x Launch Board.

    This init_STDOUT_AND_STDIN function is called follow up Board_init (), and the Board_ini() is generated by sysconfig(Which include MCAN init).

    Meanwhile, If we remove freopen function (STDOUT_AND_STDIN) as below red box code, the MCAN init normally. Or you can test it with your side when add these the code in the red box after MCAN init code, the MCAN can not work. Please confirm the root cause about MCAN init abnormally when called this stdout functions here? 

  • Hello,

    Can you provide more information on what the freopen and setvbuf functions are doing?

    What is the difference between line 201and 205? Seems like these are calling the same function, just one is assigning the return value to variable *stdout_fp.

    Should freopen() be called back to back like this?

    I can see no reason why including these functions would result in MCAN not working. Is the MCAN being properly configured via Board_Init, and then failing to operate, or is it improperly configured from the start and never operates?

    Just for sanity sake, the SCIB module you are using for stdout, what pins are used by the peripheral? I want to confirm there isn't any pinmux clashing with MCAN pins.

    Best Regards,

    Zackary Fleenor

  • Hi Fleenor, 

    I have sent the reproduced issue project to you over email.

  • Thank you for sharing the project. Can you provide any answers for the questions in the previous response?

    Best Regards,

    Zackary Fleenor

  • Yes, CAN being properly configured via Board_Init. If we configure again after  line 201and 205 code, the MCAN init is okay and MCAN can work normally.

  • Does reconfiguring MCAN after calling the freopen functions resolve your issue?

    Can you share the latest project files for reference?

    Best Regards,

    Zackary Fleenor

  • Yes, reconfiguring MCAN after calling the freopen functions resolve customer issue. Please help figure out the reason why it will affect MCAN init? Thanks.