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.

AM3517 HECC bit timing problem in WINCE BSP

Other Parts Discussed in Thread: AM3517

My bsp version is BSP_WINCE_ARM_A8_01_01_00.

HECC driver (PLATFORM\COMMON\SRC\SOC\COMMON_TI_V1\COMMON_TI\HECC\omap_hecc.cpp) in this BSP using 66.7% as its sample point.

We want to change sample point to 87.5% to meet CANOpen and DeviceNet requirement.

But we can't setting 87.5% sample point at high baud rate such as 250k 500k 800k 1000k...(omap_hecc.cpp->FindBestCanBitTiming)

Is there any solution about this?

  • The sample point depends on the baudrate, input clock of the HECC module (13 MHz), and granularity of the segment registers in the HECC controller. As there are many parameters involved, some couple baudrate/sampling points may not be achieved accurately. My advice for you is to try to compute manually what would be the size of the TS1 and TS2 segments you need to achieve you 87.5% sampling point at high baudrates, and see if it fits into the BRP, TSEG1 and TSEG2 registers from the AM3517 datasheet.

    If it appears that this should work, then you should try to force these valueds into the driver and see what happens.

  • I've test it from sample point 85% to 90%, here is my modified source code and RETAILMSG.

    // source code
    BOOL FindBestCanBitTiming(int Fin,int bitrate,int* pBrp,int* Tseg1,int* Tseg2, SAMPLE_POINT_STATE* sample_point)
    {
    #define MAX_ERROR_PERTHOUSAND   20
        int TSEG1,TSEG2,BRP;
        int TSEGTotal = 0;   
        BOOL found;
        DWORD actualFin;
        //bitrate = Fin / (BRP *(TSEG1+TSEG2+1);

        found = FALSE;
        BRP = 255;
        while (BRP)
        {
            TSEGTotal = Fin / (bitrate * BRP);
            actualFin = TSEGTotal * (bitrate * BRP);
            if (((Fin-actualFin) / (Fin/1000)) < MAX_ERROR_PERTHOUSAND)
            {   /* 
                if ((TSEGTotal < (16+8+1)) && (TSEGTotal >=4))
                {
                    break;
                }
                */
                if( (TSEGTotal==9) || (TSEGTotal==17) ) //87.5%
                {
                    *sample_point = SAMPLE_POINT_875;
                    break;
                }
                else if( (TSEGTotal==10) || (TSEGTotal==19) ) //88.9..%
                {
                    *sample_point = SAMPLE_POINT_889;
                    break;
                }
                else if( (TSEGTotal==8) || (TSEGTotal==15) ) //85.7%
                {
                    *sample_point = SAMPLE_POINT_857;
                    break;
                }
                else if( (TSEGTotal==11) || (TSEGTotal==21) ) //90%
                {
                    *sample_point = SAMPLE_POINT_900;
                    break;
                }
            }
            BRP--;
        }
       
        if(!BRP)
        {
            RETAILMSG(1,(TEXT("can't find proper setting for bitrate:%d\r\n"),bitrate));
            return FALSE;
        }
       
        switch(*sample_point)
        {
            case SAMPLE_POINT_875:
                if(TSEGTotal==9)
                {
                    TSEG1 = 7;
                    TSEG2 = 1;
                }
                else
                {
                    TSEG1 = 14;
                    TSEG2 = 2;
                }
                break;
            case SAMPLE_POINT_889:
                if(TSEGTotal==10)
                {
                    TSEG1 = 8;
                    TSEG2 = 1;
                }
                else
                {
                    TSEG1 = 16;
                    TSEG2 = 2;
                }
                break;
            case SAMPLE_POINT_857:
                if(TSEGTotal==8)
                {
                    TSEG1 = 6;
                    TSEG2 = 1;
                }
                else
                {
                    TSEG1 = 12;
                    TSEG2 = 2;
                }
                break;
            case SAMPLE_POINT_900:
                if(TSEGTotal==11)
                {
                    TSEG1 = 9;
                    TSEG2 = 1;
                }
                else
                {
                    TSEG1 = 18;
                    TSEG2 = 2;
                }
                break;
            default:
                RETAILMSG(1,(TEXT("can't find proper setting for bitrate:%d\r\n"),bitrate));
                return FALSE;
        }

        RETAILMSG(1,(TEXT("bitrate:%d actualFin:%u, BRP:%d TSEGTotal:%d TSEG1:%d TSEG2:%d\r\n"), bitrate, actualFin, BRP, TSEGTotal, TSEG1, TSEG2));
       
        *pBrp = BRP;
        *Tseg1 = TSEG1;
        *Tseg2 = TSEG2;
        return TRUE;
    }

     

    // RETAILMSG, test from 10K to 1000K

    bitrate:10000 actualFin:12960000, BRP:162 TSEGTotal:8 TSEG1:6 TSEG2:1
    bitrate:20000 actualFin:12960000, BRP:81 TSEGTotal:8 TSEG1:6 TSEG2:1
    bitrate:50000 actualFin:12800000, BRP:32 TSEGTotal:8 TSEG1:6 TSEG2:1
    bitrate:100000 actualFin:12800000, BRP:16 TSEGTotal:8 TSEG1:6 TSEG2:1
    bitrate:125000 actualFin:13000000, BRP:13 TSEGTotal:8 TSEG1:6 TSEG2:1
    bitrate:250000 actualFin:12750000, BRP:3 TSEGTotal:17 TSEG1:14 TSEG2:2
    can't find proper setting for bitrate:500000
    bitrate:800000 actualFin:12800000, BRP:2 TSEGTotal:8 TSEG1:6 TSEG2:1
    can't find proper setting for bitrate:1000000

  • can your wince hecc at   1m (1000k)   send message?