USB - USART communication problems

Posted on
  • Hello, I have been working with the MDBT42Q, I want to control it using the USART1 (pins D8 and D6). I use the REPL console to send the code, after that I use the REPL to check some pin status using directly the analogRead function or modify the value of a pin using digitalWrite.

    The device works as expected, but after some time (random) it become unstable.

    After checking the communication logs I've been able to found some errors that are appearing randomly.

    This errors are:
    1.- Execution Interrupted during event processing.\r\n
    2.- New interpreter error: MEMORY\r\n
    3.- ERROR: Ctrl-C while processing interval - removing it.\r\n
    4.- New interpreter error: CALLBACK\r\n
    5.- New interpreter error: MEMORY_BUSY\r\n
    6.- Execution Interrupted\r\n
    7.- New interpreter error: FIFO_FULL\r\n

    I've been searching for detailed information about it and I couldn't find any reason to have this unexpected behaviour. It seems that this kind of errors are related on execution conditions (if there are a lot of calls to a big function, etc)

    I would like to know if there is any function that helps me to debug this errors, allow me to check the free RAM memory or the setWatch queue status.

    A part of that I would like to know if it's posible to enable software or hardawre flow control on the USART1? Is it posible to disble the BLE console?

    Thank you in advance

  • New interpreter error: MEMORY

    I'd focus on this as it's the first one. It means you've run out of memory - presumably your code has some kind of memory leak or just keeps putting data into an array.

    I'd use process.memory().usage to see how much memory is used - you may see it going down over time. Best bet is to see if you can figure out which function calls cause the memory usage to go down and you can work from there.

    You can also use E.getSizeOf to recursively show how much memory is used by various different things. If you haven't already I'd update to the latest cutting edge build of Espruino as there were some changes made a month or two ago that make E.getSizeOf return more useful information

    it's posible to enable software or hardawre flow control on the USART1?

    Yes - Serial1.setup -Ā­al_setup

    Is it posible to disble the BLE console?

    Yes, you can just set uart:false in NRF.setServices

  • Hi Gordon,

    Thank you for your fast response.

    I've checked using the process.memory().usage. Finally I found that there were a pin that was not pulled up or down and it was used in a setWatch. This pin was also near to another pin used for I2C communication, so it receive a lot of electrilcal noise. The state of the pin was changing extremly fast and uncontrollable, filling the buffer. After removing the setWatch the error has disapeared.

    Thank you for all.

  • That's great - good to know - thanks for the update!

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

USB - USART communication problems

Posted by Avatar for lluisrovira @lluisrovira