diff --git a/ch32v003fun/ch32v003fun.c b/ch32v003fun/ch32v003fun.c index f25595f66cde4f1debce05d487a311d514fc721e..3cc57c37e2cd7216fc9d46b790b610f5d20f8cf9 100644 --- a/ch32v003fun/ch32v003fun.c +++ b/ch32v003fun/ch32v003fun.c @@ -856,12 +856,14 @@ int _write(int fd, const char *buf, int size) char buffer[4] = { 0 }; int place = 0; + uint32_t timeout = 80000; // Give up after ~20ms while( place < size ) { int tosend = size - place; if( tosend > 7 ) tosend = 7; - while( ((*DMDATA0) & 0x80) ); + while( ((*DMDATA0) & 0x80) ) + if( timeout-- == 0 ) return place; uint32_t d; int t = 3; diff --git a/examples/debugprintfdemo/debugprintfdemo.c b/examples/debugprintfdemo/debugprintfdemo.c index 297d2b8d640e1d1ac0aaa9202aaad30d39be630e..576f199d9dd336c06f9236dfbc399f2d9f430cb9 100644 --- a/examples/debugprintfdemo/debugprintfdemo.c +++ b/examples/debugprintfdemo/debugprintfdemo.c @@ -24,9 +24,8 @@ int main() while(1) { GPIOD->BSHR = 1 | (1<<4); // Turn on GPIOD0 - //Delay_Ms( 50 ); - GPIOD->BSHR = (1<<16) | ( 1<<(4+16) ); // Turn off GPIOD0 - //Delay_Ms( 50 ); printf( "+%d\n", count++ ); + GPIOD->BSHR = (1<<16) | ( 1<<(4+16) ); // Turn off GPIOD0 + printf( "-%d\n", count++ ); } }