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.

DRV8301-69M-KIT: Serial port (SCI) not working in interrupt mode

Part Number: DRV8301-69M-KIT
Other Parts Discussed in Thread: MOTORWARE, C2000WARE

I am trying to interface to the DRV8301-69m SCI B. I located a document named Hardware Abstraction Layer (HAL) Module of Motorware from TI and the section 6.7 illustrates how to add SCI/UART functionality to a Motorware project. My motor does not have an encoder so I have used the CAP1 and CAP2 GPIO pins that are present in the external connector on the eval board. I have set up the GPIO to point at these for the Rx and Tx of SCI-B. I have made the modifications per the article and in 6.7.9 it shows how to use a simple polling to receive data. That works as it is shown. However I want to use the port in interrupt mode so I followed the next steps starting in 6.7.10. The code compiles and it looks like I have it matching. I referred back to 6.7.9 where it put  

if(SCI_rxDataReady(halHandle->sciBHandle))

  { while(SCI_rxDataReady(halHandle->sciBHandle) == 0);

  dataRx = SCI_getDataNonBlocking(halHandle->sciBHandle, &success);

  success = SCI_putDataNonBlocking(halHandle->sciBHandle, dataRx);

}

for polling. I removed this code and tried to run the lab (BTW I am using Lab 5b as the basis). It runs fine except the interrupt is never raised and therefore does not receive the incoming data. 

Can someone help me determine what I am missing by following this example? How/where can I look to see what is failing. I know the external source for serial input is working since the polling mode works and I am using the same setup.

Thanks in advance.

  • Terry,

    Thanks for reaching out to the E2E, we're still working on getting the correct TI engineers looking at your post.  We should have a reply later today.

    Best,

    Matthew

  • It runs fine except the interrupt is never raised and therefore does not receive the incoming data. 

    Do you mean the SCIB interrupt? Do you add the ISR as the steps 11~15?

    And please check if the baud rates are set the same value for both F2806x and the other controller you used. And you might try to check if there is signals on the SCI bus with an oscilloscope.

  • Thanks for the reply. Yes I did the steps 11 -15 but it was not working OR giving an error indication. It turned out to be a typo in the code that was the interrupt service routine. It is not clear why placing a breakpoint inside the ISR did not ever work or allow me to single step through the code. I understand that it is an interrupt and stopping the processor would stop other functions but should it not have broken at the breakpoint or at least told me that it wouldn't? Is there another way to debug within ISRs?

    Having made it through that there is still another issue with the implementation of the serial port from the HAL document. In Section 6.7.11 it discusses giving the ADC interrupt the highest priority so that the serial port does not supersede any motor functions. The instructions show to change the code in the hal.c file function HAL_enableAdcInts. The changes are shown with *********** beside it and is commented out. A similar change is shown in hal.h added below also with the change to line with ******** and commented out. The logic of why this should be done makes sense but if I uncomment these lines the serial ISR works fine but the motor will not run. If I leave these lines commented and revert to the original. The motor runs fine. The base project is lab5b. If the interrupt change is helpful I want to make it because it seems to say that I have a possible ISR collision although in quick testing I don't see any. Can you tell me the fix please?

    void HAL_enableAdcInts(HAL_Handle handle)
    {
    HAL_Obj *obj = (HAL_Obj *)handle;


    // enable the PIE interrupts associated with the ADC interrupts
    //PIE_enableAdcInt(obj->pieHandle,ADC_IntNumber_1HP); ******************
    PIE_enableAdcInt(obj->pieHandle,ADC_IntNumber_1);


    // enable the ADC interrupts
    ADC_enableInt(obj->adcHandle,ADC_IntNumber_1);


    // enable the cpu interrupt for ADC interrupts
    //CPU_enableInt(obj->cpuHandle,CPU_IntNumber_1);******************************
    CPU_enableInt(obj->cpuHandle,CPU_IntNumber_10);

    return;
    } // end of HAL_enableAdcInts() function

    static inline void HAL_initIntVectorTable(HAL_Handle handle)
    {
    HAL_Obj *obj = (HAL_Obj *)handle;
    PIE_Obj *pie = (PIE_Obj *)obj->pieHandle;


    ENABLE_PROTECTED_REGISTER_WRITE_MODE;

    //pie->ADCINT1_HP = &mainISR;***************
    pie->ADCINT1 = &mainISR;
    pie->SCIRXINTB = &sciBRxISR;

    DISABLE_PROTECTED_REGISTER_WRITE_MODE;

    return;
    }

  • You can't set breakpoint at anywhere since the optimization is set to level 2 by default in the project. You don't need to set the ADC interrupt to high priority for motor control if  nesting interrupt is not used and there is not too many codes in SCI ISR.

    You might refer to the example in C2000Ware to enable loop back mode check if the SCI configuration is correct. You can find the SCI example in the folder below after the C2000Ware is installed. http://www.ti.com/tool/c2000ware

    C:\ti\c2000\C2000Ware_3_04_00_00\device_support\f2806x\examples\c28

    BTW, you need to change the HAL_acqAdcInt() as below in hal.h file if you want to use the ADCINT1_HP interrupt.

    static inline void HAL_acqAdcInt(HAL_Handle handle,const ADC_IntNumber_e intNumber)
    {
    HAL_Obj *obj = (HAL_Obj *)handle;


    // clear the ADC interrupt flag
    ADC_clearIntFlag(obj->adcHandle,intNumber);


    // Acknowledge interrupt from PIE group 10
    // PIE_clearInt(obj->pieHandle,PIE_GroupNumber_10);
    PIE_clearInt(obj->pieHandle, PIE_GroupNumber_1);

    return;
    } // end of HAL_acqAdcInt() function

  • Thanks I appreciate this a great deal! The change in the HAL_acqAdcInt was the missing piece and it is not in the HAL document I referred to above - at least the version I have. It is all working fine now and I really thank you for the response.