Skip to content

Commit

Permalink
Workaround for USB memory bandwidth at very slow CPU speeds
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulStoffregen committed May 15, 2020
1 parent 9f7a6e4 commit e5a9b19
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions teensy4/usb_desc.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@
#include "avr_functions.h"
#include "avr/pgmspace.h"

// At very slow CPU speeds, the OCRAM just isn't fast enough for
// USB to work reliably. But the precious/limited DTCM is. So
// as an ugly workaround, undefine DMAMEM so all buffers which
// would normally be allocated in OCRAM are placed in DTCM.
#if defined(F_CPU) && F_CPU < 30000000
#undef DMAMEM
#endif

// USB Descriptors are binary data which the USB host reads to
// automatically detect a USB device's capabilities. The format
// and meaning of every field is documented in numerous USB
Expand Down
9 changes: 9 additions & 0 deletions teensy4/usb_serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@
#if defined(CDC_STATUS_INTERFACE) && defined(CDC_DATA_INTERFACE)
//#if F_CPU >= 20000000

// At very slow CPU speeds, the OCRAM just isn't fast enough for
// USB to work reliably. But the precious/limited DTCM is. So
// as an ugly workaround, undefine DMAMEM so all buffers which
// would normally be allocated in OCRAM are placed in DTCM.
#if defined(F_CPU) && F_CPU < 30000000
#undef DMAMEM
#define DMAMEM
#endif

uint32_t usb_cdc_line_coding[2];
volatile uint32_t usb_cdc_line_rtsdtr_millis;
volatile uint8_t usb_cdc_line_rtsdtr=0;
Expand Down

0 comments on commit e5a9b19

Please sign in to comment.