Artificial intelligence is deeply involved in the debugging of embedded controllers---ChatGPT answers the problem of invalidation of the ACT bit of the TC377 PSRi register

Friends who do embedded development, there are benefits!

When encountering difficulties in the debugging process, we often look for manuals, search the Internet, and find FAE to solve them. Now that we have ChatGPT, we try to ask the debugging questions, as follows

 First my problem description :

When setting the MCMCAN controller mode, what would cause the TC377 cpu PSRi register ACT bit to not change from sync to idle when CCCRi.INT is set to NORMAL?

ChatGPT: 

The TC377 CPU is a complex system and there could be several reasons why the ACT bit of the PSRi register does not change from sync to idle when setting the MCMCAN controller mode. However, the following are some possible reasons that might cause this behavior:

1. Interrupts not enabled : The MCMCAN controller requires interrupts to be enabled to change the PSRi register from Synchronous to Idle. If interrupts are not enabled, the ACT bit will remain in the synchronous state.

2. The MCMCAN controller is not properly initialized: The MCMCAN controller needs to be properly initialized to start sending and receiving messages. If the controller is not properly initialized, it may fail to transition to idle state.

3. The MCMCAN controller is not configured correctly: The MCMCAN controller has various configuration parameters that need to be set correctly for proper operation. If these parameters are not set correctly, the controller may fail to transition to idle state.

4. Bus contention: If there is bus contention on the CAN bus, the MCMCAN controller may not be able to complete its initialization sequence, which may prevent it from transitioning to the idle state.

5. Hardware Problem: There may be a hardware problem with the TC377 CPU or MCMCAN controller preventing the ACT bit from transitioning to the Idle state.

Determining the root cause of the problem may require further analysis, such as debugging software or checking hardware settings.

 Continue to ask:

What is the rationale for the first reason?

ChatGPT:

Of course, I'm happy to explain the rationale behind the first possible reason I mentioned.

The MCMCAN controller generates an interrupt to signal the CPU when there is new data to transmit or receive. Interrupts allow the CPU to quickly respond to new data and initiate necessary processing. The PSRi register in the TC377 CPU indicates the current state of the MCMCAN controller, including whether it is idle or synchronizing.

When the MCMCAN controller is in the process of initializing or synchronizing, the ACT bit in the PSRi register will be set to the synchronous state. Once the controller is initialized and ready to send or receive data, the ACT bit should transition to the idle state.

However, if interrupts are not enabled, the CPU will not be able to respond to interrupt requests from the MCMCAN controller. As a result, the MCMCAN controller may not be able to complete its initialization sequence and the ACT bit may be stuck in the Sync state.

Therefore, enabling interrupts is a critical step to ensure the correct operation of the MCMCAN controller and the transition of the PSRi registers to the idle state. By enabling interrupts, the CPU will be able to receive and respond to interrupt requests from the MMCCAN controller, allowing it to complete the initialization sequence and transition to the idle state.

 Going deeper:

Can you give me more information about the second reason? (The second reason is "not properly initialized")

ChatGPT:

certainly! Here are more details on the second possible cause I mentioned:

The MCMCAN controller needs to be properly initialized to start sending and receiving messages. Initialization typically involves configuring the controller's registers, setting up message objects, and configuring the clock and baud rate settings for the CAN bus. If any of these steps are not performed correctly, the controller may fail to transition to the Idle state and the ACT bit of the PSRi register may be stuck in the Sync state.

To diagnose if the problem is related to MCMCAN controller initialization, you can try the following steps:

1. Verify that the MCMCAN controller is properly enabled and configured for operation.

2. Make sure the clock and baud rate settings of the CAN bus are correct.

3. Check that the message object is properly initialized and used correctly in the application code.

4. Make sure that the software correctly configures the controller's registers, especially those related to initialization.

5. Check that the bus is properly terminated and that there are no bus contention or other hardware-related problems.

By verifying that the MCMCAN controller is properly initialized and there are no hardware or software related issues, you can help ensure that the ACT bit of the PSRi register will transition to the idle state as expected.

continue...

How to verify always and baud rate is configured correctly?

ChatGPT:

To verify that the clock and baud rate settings for the CAN bus are set correctly, you can perform the following steps:

 1. Check the settings in the clock control register (CCR) of the CAN module. The CCR controls the clock source and frequency of the CAN module, which is used to generate the baud rate of the CAN bus. Make sure the CCR settings match the clock source and frequency required by the CAN module.

 2. Calculate the actual baud rate used on the CAN bus. The actual baud rate c can be calculated from the bit timing settings used in the bit timing register (BTR). The BTR setting controls the timing of the CAN bus signals and depends on the desired baud rate, clock frequency and sampling point.

3. Verify that the calculated actual baud rate matches the desired baud rate. If the calculated actual baud rate is significantly different than the desired baud rate, there may be a problem with the clock or baud rate settings.

 4. Use an oscilloscope or CAN bus analyzer to verify the waveform of the CAN bus signal. The waveform should match the expected waveform for the desired baud rate and bit timing settings. If the waveform does not match the expected waveform, there may be a problem with the clock or baud rate settings.

According to the guidelines of ChatGPT, I checked the interrupt registration, CAN clock configuration, baud rate, and CAN controller mailbox configuration. By observing the relevant registers after initialization, no clock or baud rate configuration problems were found. The problem of bus occupation is ruled out. The line of defense for troubleshooting the problem lies in the synchronization mechanism between the CAN controller and the communication.

Use an oscilloscope to measure the EN and STB_N pins of the CAN transceiver, which are high and low respectively, and then send a message through the CANOE host computer to measure the RX TX pins, and find that they are all continuous low signals without any signal. Go check the manual of the CAN transceiver and find that there is a problem with the working mode setting of the transceiver. If you want the transceiver to work in Normal mode, you need to set both the EN and STB_N pins to HIGH.

After changing the STB_N pin to HIGH, the host computer sends a message, measures the RX pin, and a signal appears, then go to observe the PSRi.ACT bit, and after CCCRi.INIT changes to Normal, the PSRi.ACT bit immediately changes to Idle.

Problem solved!

Supongo que te gusta

Origin blog.csdn.net/weixin_46481662/article/details/129810240
Recomendado
Clasificación