Wiz-IO / platformio-quectel-examples

Examples for PlatformIO Quectel
29 stars 21 forks source link

Ql_SPI_WriteRead() crashes #5

Closed ASL07 closed 4 years ago

ASL07 commented 4 years ago

Hi, I am trying to use SPI on this device with the MAX31856 converter. The device is properly wired, and I am calling Ql_SPI_Init and Ql_SPI_Config, which return correctly. I am using HW SPI with the HW SPI pins of the BC66 DevKit from Olimex. However, when I call Ql_SPI_WriteRead(), the device crashes, the function never returns. Analyzing the signals on the scope, I can see that the CS/MISO/MOSI/CLK pins never change value. Am I missing anything? Please see a simplified version of my code below :


void proc_main_task(s32 task_id)
{
    ST_MSG msg;
    s32 ret;

    // Register & open UART port
    Ql_UART_Register(m_my_uart, CallBack_UART_Hdlr, NULL);
    Ql_UART_Open(m_my_uart, 115200, FC_NONE);

    // Disable sleep mode
    Ql_SleepDisable();

    APP_DEBUG("<-- OpenCPU: Starting App-->\r\n");

    Ql_SPI_Init(0, PINNAME_SPI_SCLK, PINNAME_SPI_MISO, PINNAME_SPI_MOSI, PINNAME_SPI_CS, 1);
    Ql_SPI_Config(0, true, 0, 1, 500);

    u8 w_buf[2] = { MAX31856_CONFIG_REG, 0 };
    Ql_SPI_WriteRead(0, MAX31856_CONFIG_REG, 1, w_buf[1], 1);
    while(1)
    {
        // Ql_OS_GetMessage is an important system function which enables the Embedded Application to 
        // retrieve messages from message queue of the task.
        Ql_OS_GetMessage(&msg);

        // Process message
        switch(msg.message)
        {
            // MSG_ID_RIL_READY is a system message that RIL module sends to main task
            case MSG_ID_RIL_READY:
                //Before use the RIL feature, you must initialize it by calling Ql_RIL_Initialize() 
                //After receive the 'MSG_ID_RIL_READY' message.
                Ql_RIL_Initialize();
                break;

            // MSG_ID_URC_INDICATION is a system message that indicates a new URC was received
            case MSG_ID_URC_INDICATION:
                msg_process(&msg);
                break;

            default:
                break;
        }
    }
}
Wiz-IO commented 4 years ago

Hi Questions for Quectel :) debug/print arguments s32 Ql_SPI_Write(u32 chnnlNo, u8 * pData, u32 len); may pData is NULL

Wiz-IO commented 4 years ago

and try init I2C/SPI after Sim Ready, give second then init if work - write issue to Quectel :)

ASL07 commented 4 years ago

It was my fault. I have got it working now. I will post the proper code when I get time. Thanks for the support @Wiz-IO