S32K144 problems with LPSPI 16bit transmission to UJA1169

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

S32K144 problems with LPSPI 16bit transmission to UJA1169

3,860 Views
carpenter
Contributor II

Hello,

I have some problems with the SPI communication. When loading the transmit data register (TDR) with a 16-bit value (in the traced example: 0x0204), it only transferes the first 8-bit (0x02). The second 8-bits are always zero (instead of 0x04).

This is weird for me, because:

- in the transmit control register I've set the frame size to 16 bit (0xf)

- I can verify that there are 16 clock cycles on the SCLK line

- I see that there changeline is set correctly over this time

- I imported the SBC UJA1169 driver from processor expert and verified that it is configured as in the example code (in my application I had to change PCS from PCS2 to PCS0)

 I've a PCB with the S32K144 controller, using the system base chip UJA1169.

Data word to send:

pastedImage_2.png

SPI configuration:

pastedImage_1.png

Any hints for me?

kind regards

Tags (2)
0 Kudos
7 Replies

1,866 Views
razva_tilimpea
NXP Employee
NXP Employee

Hi,

The SBC example provided on the SDK works fine?

Best regards,

Razvan

1,866 Views
carpenter
Contributor II

Hi Razvan,

Thanks for this hint. I've ported the sbc_uja1169 example to my PCB now. After the second run, everything was working as expected.

Probably because the factories settings were not set correctly before. Either FNMC was enabled or SDMC was enabled or SLPC was ignored.

Best regards,

carpenter

So integrating following code from the sbc uja1169 example worked for me:

     sbc_factories_conf_t factoriesConf; 

     /* Test require correct factory settings for example.
     * FNMC bit must be disabled, SBC_UJA_SBC_SDMC_DIS must be disabled
     * and slpc must be allowed. */
    status = SBC_GetFactoriesSettings(&factoriesConf);
    DEV_ASSERT(status == STATUS_SUCCESS);
    if(factoriesConf.control.fnmc == SBC_UJA_SBC_FNMC_EN ||
            factoriesConf.control.sdmc == SBC_UJA_SBC_SDMC_EN ||
            factoriesConf.control.slpc == SBC_UJA_SBC_SLPC_IG)
    {
        /* Set correct settings. */
        factoriesConf.control.fnmc = SBC_UJA_SBC_FNMC_DIS;
        factoriesConf.control.sdmc = SBC_UJA_SBC_SDMC_DIS;
        factoriesConf.control.slpc = SBC_UJA_SBC_SLPC_AC;

        /* If this function return SBC_NVN_ERROR. Factory settings must be preset
         * to default state by Hardware configuration. Please read
         * SBC_ChangeFactoriesSettings descriptions for correct settings.
         * Conditions for Hardware reset value are
         * -pin RSTN is held LOW
         * -CANH is pulled up to VBAT
         * -CANL is pulled down to GND
         * When HW reset is done you can change factory settings by running
         * this example. Be carefully device will be reseted,
         * initialization sequence must be done again. Run the example again
         * with new configuration.
         * */
        status = SBC_ChangeFactoriesSettings(&factoriesConf);
        DEV_ASSERT(status == STATUS_SUCCESS);
    }

0 Kudos

1,867 Views
razva_tilimpea
NXP Employee
NXP Employee

Hi,

Probably the hardware reset of the board didn't worked at the first try. 

So, now your application works fine?

Best regards,

Razvan

0 Kudos

1,867 Views
carpenter
Contributor II

Yes, thank you!

0 Kudos

1,867 Views
fanchang
Contributor I

I had use this example, I had press sw9 and send some data to evbboard (500kbps ID=0x12),but it hadn't responed. how to wake-up the uja1169 and receive and send data to CanAnalysisTools?thank you very much.

0 Kudos

1,868 Views
razva_tilimpea
NXP Employee
NXP Employee

Hi,

fanchang‌ you are the same person as carpenter?

The behavior describer by fanchang‌ can be cause by some power supply issue (the SBC is not powered at 12V) or SBC is in FNMC(forced normal mode).

If you want to use SBC only as CAN communication you can use SBC uninitialized because by default it is configured in FNMC and CAN transceiver is enabled. 

If you want to use SBC in Normal mode please follow the instructions from example documentation where you can find how to disable FNMC.

Best regards,

Razvan

1,868 Views
pekor
Contributor II

Hello,

carpenter and I are working with same SBC (same project by the way). Maybe this issue is connected maybe is not.

At this stage I wanted to use CAN communication only. As You said SBC should be in FNMC and CAN transceiver should be enabled at this point. But unfortunately only sending CAN messages works, but not receiving.

I'm using FLEXCAN library. When FLEXCAN_DRV_Receive is called and I check the the transfer status the answer is always STATUS_BUSY.

The app is not going through the callback (and so through FLEXCAN_DRV_IRQHandler as well), but when I'm use FLEXCAN_DRV_Send everything seems to work as it should.

Here is a sample code (only FLEXCAN code):

bool canDataReceived = false;

#define RX_MB (1U)
#define TX_MB (0U)
#define MSG_ID_1 0x1B0
#define MSG_ID_2   0x1C0

static void flexcan0_Callback(uint8_t instance,
     flexcan_event_type_t eventType,
     flexcan_state_t *flexcanState)
{
     (void)flexcanState;
     (void)instance;

     switch(eventType)
     {
     case FLEXCAN_EVENT_RX_COMPLETE:
          canDataReceived = true;
          break;
     case FLEXCAN_EVENT_TX_COMPLETE:
          break;
     default:
          break;
     }
}

int main(void)
{
(...)

    FLEXCAN_DRV_Init(INST_CANCOM1, &canCom1_State, &canCom1_InitConfig0);
    FLEXCAN_DRV_ConfigTxMb(INST_CANCOM1, TX_MB, &dataInfo, MSG_ID_1);

    FLEXCAN_DRV_ConfigRxMb(INST_CANCOM1, RX_MB, &dataInfo, MSG_ID_2);
    FLEXCAN_DRV_InstallEventCallback(INST_CANCOM1, flexcan0_Callback, NULL);

    /* Define receive buffer */
    flexcan_msgbuff_t recvBuff;
    FLEXCAN_DRV_Receive(INST_CANCOM1, RX_MB, &recvBuff);

    /* Wait until the previous FlexCAN receive is completed */
    //while(FLEXCAN_DRV_GetTransferStatus(INST_CANCOM1, RX_MB) == STATUS_BUSY);

    for (;;)
    {
        if (canDataReceived)
        {
             FLEXCAN_DRV_Receive(INST_CANCOM1, RX_MB, &recvBuff);
             canDataReceived = false;
        }
    }
}

Do You (or anyone) know what could possibly go wrong?

0 Kudos