소스 검색

Configure UART clock before use

main
PaulStoffregen 5 년 전
부모
커밋
7548dc7492
2개의 변경된 파일5개의 추가작업 그리고 3개의 파일을 삭제
  1. +1
    -3
      teensy4/debugprintf.c
  2. +4
    -0
      teensy4/startup.c

+ 1
- 3
teensy4/debugprintf.c 파일 보기

@@ -80,10 +80,8 @@ void putchar_debug(char c)
__attribute__((section(".progmem")))
void printf_debug_init(void)
{
// turn on Serial4, run using 24 MHz clock (works if PLL3 off or bypassed)
CCM_CCGR0 |= CCM_CCGR0_LPUART3(CCM_CCGR_ON);
CCM_CCGR0 |= CCM_CCGR0_LPUART3(CCM_CCGR_ON); // turn on Serial4
IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_06 = 2; // Arduino pin 17
CCM_CSCDR1 = (CCM_CSCDR1 & ~CCM_CSCDR1_UART_CLK_PODF(0x3F)) | CCM_CSCDR1_UART_CLK_SEL;
LPUART3_BAUD = LPUART_BAUD_OSR(25) | LPUART_BAUD_SBR(8); // ~115200 baud
LPUART3_CTRL = LPUART_CTRL_TE;
}

+ 4
- 0
teensy4/startup.c 파일 보기

@@ -55,8 +55,12 @@ void ResetHandler(void)
for (i=0; i < 176; i++) _VectorsRam[i] = &unused_interrupt_vector;
SCB_VTOR = (uint32_t)_VectorsRam;

// Configure clocks
// TODO: make sure all affected peripherals are turned off!
// PIT & GPT timers to run from 24 MHz clock (independent of CPU speed)
CCM_CSCMR1 = (CCM_CSCMR1 & ~CCM_CSCMR1_PERCLK_PODF(0x3F)) | CCM_CSCMR1_PERCLK_CLK_SEL;
// UARTs run from 24 MHz clock (works if PLL3 off or bypassed)
CCM_CSCDR1 = (CCM_CSCDR1 & ~CCM_CSCDR1_UART_CLK_PODF(0x3F)) | CCM_CSCDR1_UART_CLK_SEL;

// must enable PRINT_DEBUG_STUFF in debug/print.h
printf_init();

Loading…
취소
저장