6 years, 9 months ago.

Can I use USBSerial with ticker?

I tried to create two ticker used for two tasks. One task is adc sampling task, the other is commad query task.

Ticker adc_sample_task; TASK FOR ADC SAMPLING

Ticker cmd_query_task; TASK FOR QUERYING CMD FROM PC

In the task for command querying, mcu queried the USBSerial port every one second to see if there are some commands which has been send from PC.

void serial_read_cmd(void) { uint8_t chr;

while (usb_serial.readable()) {

blue_led = LED_ON;

chr = usb_serial.getc();

daplink.putc(chr); }

if (chr == 'b') {

/* UPLOAD SAMPLED DATA */

red_led = LED_ON;

} else if (chr == 'e') {

/* STOP UPLOAD */

red_led = LED_OFF;

}

blue_led = LED_OFF;

return; }

When the system was powered on, everything was ok. When I input some characters from ternimal, 1. The blue led was lighted on all the time. 2. The red led had no response even I input character "b" 3. The green led which indicated sampling task was running go out all the time. I thought the program was blocked at getc() function, but I could not find the reason because the program could not be exported and could not be debugged. I was using MAX32630FTHR. I would be very appreciated if anybody would like to help me.

Be the first to answer this question.