This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

CDC ACM example

Hi everyone,

Regarding the CDC ACM example I have a question.
In the example, every time a button is pressed there is a writing. I would like the writing to happen every second regardless of the button.
I would like to remove the button and have it write every second. Is it possible? How can I change the firmware?
BR

Parents
  • Hello,

    The USB CDC ACM example from the SDK sends a test frame when button 1 is pressed.
    If you look into the source code for the example, you will see that this is done by setting and clearing the m_send_flag in the bsp_evt_handler function. The easiest way to modify the example to send the test frame periodically is to set the m_send_flag variable in a timer's callback, instead of the button press event handler. For this, you could either use the TIMER peripheral directly, or the app_timer library.

    To see how you may go about setting up a timer with the TIMER peripheral you could take a look at the TIMER example from the SDK, while if you are looking to use the app_timer library you implement it as described in the app_timer's usage section (usage of the app_timer is also shown in most of the BLE peripheral examples ).

    Please do not hesitate to ask if anything still should be unclear, or if you encounter any other issues or questions!

    Best regards,
    Karl

Reply
  • Hello,

    The USB CDC ACM example from the SDK sends a test frame when button 1 is pressed.
    If you look into the source code for the example, you will see that this is done by setting and clearing the m_send_flag in the bsp_evt_handler function. The easiest way to modify the example to send the test frame periodically is to set the m_send_flag variable in a timer's callback, instead of the button press event handler. For this, you could either use the TIMER peripheral directly, or the app_timer library.

    To see how you may go about setting up a timer with the TIMER peripheral you could take a look at the TIMER example from the SDK, while if you are looking to use the app_timer library you implement it as described in the app_timer's usage section (usage of the app_timer is also shown in most of the BLE peripheral examples ).

    Please do not hesitate to ask if anything still should be unclear, or if you encounter any other issues or questions!

    Best regards,
    Karl

Children
  • Hi, I tried to modificate CDC ACM example as you suggest me but my code doesn't work.

    Can you provide me an example that show how to do a write every seconds? Is there in the SDK?

    Sorry for my english and thanks

    BR

  • Hello,

    alexlöddeköpinge said:
    I tried to modificate CDC ACM example as you suggest me but my code doesn't work.

    I am sorry to hear that. Could you elaborate on what you did when you attempted to modify it, and how the code did not work?
    Did the code compile without warning, or did you receive an error while the program was running?
    If you could share the code in which you tried to make these modifications I can take a look, and see if I cant spot why it is not working.

    alexlöddeköpinge said:
    Can you provide me an example that show how to do a write every seconds? Is there in the SDK?

    Unfortunately we do not have such an example in our SDK - but it is really a small modification to the existing CDC ACM example. As I said in my previous comment, you can achieve this by setting the m_send_flag in a TIMER's event handler.
    You can see how to setup a TIMER to trigger periodically in the TIMER example that I linked in my previous reply.

    Looking forward to resolving this issue together,

    Best regards,
    Karl

Related