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.

capturepwmdisplay去掉pwm信号还是进回调callback



你好,我想问下cc3220在用capturepwmdisplay捕捉pwm上升沿的时候,程序里捕捉模式设的是上升沿捕捉,每捕捉一个上升沿,就会触发中断,进入capture的回调函数capturecallback(),回调函数显示捕获的脉冲个数,但是现在即使把pwm信号移除,程序还是不停的进中断,继续计数,这是怎么回事,按理说没有pwm信号了它就应该一直等待上升沿啊,怎么会还像之前一样进中断,计脉冲个数呢?

  • 请问能否给出您的具体程序?
  • 很高兴您能解决问题!
  • 这个问题解决了,不过程序里有两个地方不是特别懂

    程序里我设置的是捕获上升沿,当开始捕捉后,应该捕捉到一个上升沿就进一次capturecallback回调函数,然后semaphorep_post和while循环里的semaphorep_pend两个函数在这里具体是什么意思呢?是进一次中断,变量加1后就跳到while循环打印变量值?然后while循环里打印变量值后检测到上升沿再跳到capturecallback,如此往复吗?主要是两个semaphore_p函数的功能不太清楚。谢谢!

  • 我现在要捕获脉冲上升沿,并计数无线发送到TCP server,主要程序段如下,之前试了在缓冲区放一组数可以发送成功,当把这段capture相关函数加进来,然后在capture的回调函数里发送就不行,TCP server接收不到数据。


    void captureCallback(Capture_Handle handle, uint32_t count);
    uint32_t curCount = 0;
    static SemaphoreP_Handle captureSem;
    int32_t sock;
    int32_t status;
    int32_t TCPClient()
    {
    SlSockAddr_t *sa;
    int32_t addrSize;
    sockAddr_t sAddr;

    /* filling the TCP server socket address */
    sAddr.in4.sin_family = SL_AF_INET;
    sAddr.in4.sin_port = sl_Htons(6000);
    sAddr.in4.sin_addr.s_addr = sl_Htonl(SL_IPV4_VAL(192,168,1,100));

    sa = (SlSockAddr_t*)&sAddr.in4;
    addrSize = sizeof(SlSockAddrIn_t);

    /* Get socket descriptor - this would be the
    * socket descriptor for the TCP session.
    */
    sock = sl_Socket(SL_AF_INET, SL_SOCK_STREAM, TCP_PROTOCOL_FLAGS);
    ASSERT_ON_ERROR(sock, SL_SOCKET_ERROR);

    status = -1;

    while(status < 0)
    {
    /* Calling 'sl_Connect' followed by server's
    * 'sl_Accept' would start session with
    * the TCP server. */
    status = sl_Connect(sock, sa, addrSize);

    if(status < 0)
    {
    UART_PRINT("[line:%d, error:%d] %s\n\r", __LINE__, status, SL_SOCKET_ERROR);
    sl_Close(sock);
    return -1;
    }

    break;
    }

    SemaphoreP_Params semParams;
    Capture_Params captureParams;
    Capture_Handle capture;

    Capture_init();

    UART_PRINT("Init succeed!\n\r");

    /* Semaphore to wait for capture data */
    SemaphoreP_Params_init(&semParams);
    semParams.mode = SemaphoreP_Mode_BINARY;
    captureSem = SemaphoreP_create(0, &semParams);

    if (captureSem == NULL)
    {
    UART_PRINT("SemaphoreP_create failed!\n\r");
    while(1);
    }

    /* Setting up the Capture driver to detect two rising edges and report
    the result in microseconds
    */
    Capture_Params_init(&captureParams);
    captureParams.mode = CAPTURE_MODE_RISING_RISING;
    captureParams.periodUnit = CAPTURE_PERIOD_COUNTS;
    captureParams.callbackFxn = captureCallback;

    capture = Capture_open(Board_CAPTURE1, &captureParams);
    if (capture == NULL)
    {
    UART_PRINT("Failed to initialized Capture!\n");
    while(1);
    }

    UART_PRINT("About to Capture!\n");

    Capture_start(capture);


    return 0;
    }

    void captureCallback(Capture_Handle handle, uint32_t count)
    {
    curCount += 1;
    UART_PRINT("%d", curCount);
    status = sl_Send(sock, &curCount, sizeof(curCount), 0);
    SemaphoreP_post(captureSem);
    }