在线时间64 小时
UID3683102
注册时间2020-11-11
NXP金币0
TA的每日心情 | 擦汗 2021-3-24 09:39 |
---|
签到天数: 3 天 [LV.2]偶尔看看I
中级会员
- 积分
- 299
- 最后登录
- 2021-12-28
|
最近有一个应用觉得 SCT 很合适,特购买开发板一块用于评估 SCT 模块
1. 将 CLKOUT 输出一个 100KHz 的信号到 P0_21 (示波器可测量到)
2. 将 P0_20 作为 SCT_PIN0 并 路由到 SCT_INMUX 0
3. 设置 SCT_OUT0 为测试输出(通过单纯 MATCH 两个数值设置输出电瓶)(示波器可测量到)
4. 设置 SCT_OUT1 作为测试输出(捕捉 IN0 的下降沿设置0, 捕捉 IN0 的上升沿设置 1)(示波器无法测量到,改为MATCH事件触发后正常)
5. 将 SCT_IN0 作为时钟也不行(不论是采样或异步模式),设置后,SCT就彻底不工作了
想不到问题出在哪,特来求助各位大佬,
-------------------------------------------------------------------------------------------------------------------------------------------
SCT 部分的初始化如下:
const sctimer_config_t SCT0_initConfig = {
.enableCounterUnify = true,
.clockMode = kSCTIMER_System_ClockMode,
.clockSelect = kSCTIMER_Clock_On_Rise_Input_0,
.enableBidirection_l = false,
.enableBidirection_h = false,
.prescale_l = 0U,
.prescale_h = 0U,
.outInitState = (uint8_t)(0),
.inputsync = 1 << 0U
};
uint32_t SCT0_event[5];
static void SCT0_init(void)
{
SCTIMER_Init(SCT0, &SCT0_initConfig);
/* Initialization of state 0 */
SCTIMER_CreateAndScheduleEvent(SCT0, kSCTIMER_MatchEventOnly, 1, kSCTIMER_Out_0, kSCTIMER_Counter_U, &SCT0_event[0]);
SCTIMER_SetupOutputClearAction(SCT0, kSCTIMER_Out_0, SCT0_event[0]);
SCTIMER_CreateAndScheduleEvent(SCT0, kSCTIMER_MatchEventOnly, 6, kSCTIMER_Out_0, kSCTIMER_Counter_U, &SCT0_event[1]);
SCTIMER_SetupOutputSetAction(SCT0, kSCTIMER_Out_0, SCT0_event[1]);
SCTIMER_CreateAndScheduleEvent(SCT0, kSCTIMER_MatchEventOnly, 16, kSCTIMER_Out_0, kSCTIMER_Counter_U, &SCT0_event[2]);
SCTIMER_SetupCounterLimitAction(SCT0, kSCTIMER_Counter_U, SCT0_event[2]);
SCTIMER_CreateAndScheduleEvent(SCT0, kSCTIMER_InputFallEvent, 0, kSCTIMER_Input_0, kSCTIMER_Counter_U, &SCT0_event[3]);
SCTIMER_SetupOutputClearAction(SCT0, kSCTIMER_Out_1, SCT0_event[3]);
SCTIMER_CreateAndScheduleEvent(SCT0, kSCTIMER_InputRiseEvent, 0, kSCTIMER_Input_0, kSCTIMER_Counter_U, &SCT0_event[4]);
SCTIMER_SetupOutputSetAction(SCT0, kSCTIMER_Out_1, SCT0_event[4]);
SCTIMER_StartTimer(SCT0, kSCTIMER_Counter_U);
}
IO 部分的初始化如下
void BOARD_InitPins(void)
{
/* Enables clock for IOCON.: enable */
CLOCK_EnableClock(kCLOCK_Iocon);
/* Enables clock for switch matrix.: enable */
CLOCK_EnableClock(kCLOCK_Swm);
/* SCT_PIN0. Assign to pin using the switch matrix 0 */
INPUTMUX_AttachSignal(INPUTMUX, 0U, kINPUTMUX_SctPin0ToSct0);
const uint32_t DEBUG_UART_RX = (/* Selects pull-up function */
IOCON_PIO_MODE_PULLUP |
/* Enable hysteresis */
IOCON_PIO_HYS_EN |
/* Input not invert */
IOCON_PIO_INV_DI |
/* Disables Open-drain function */
IOCON_PIO_OD_DI |
/* Bypass input filter */
IOCON_PIO_SMODE_BYPASS |
/* IOCONCLKDIV0 */
IOCON_PIO_CLKDIV0);
/* PIO1 PIN16 (coords: 36) is configured as USART0, RXD. */
IOCON_PinMuxSet(IOCON, IOCON_INDEX_PIO1_16, DEBUG_UART_RX);
const uint32_t DEBUG_UART_TX = (/* Selects pull-up function */
IOCON_PIO_MODE_PULLUP |
/* Enable hysteresis */
IOCON_PIO_HYS_EN |
/* Input not invert */
IOCON_PIO_INV_DI |
/* Disables Open-drain function */
IOCON_PIO_OD_DI |
/* Bypass input filter */
IOCON_PIO_SMODE_BYPASS |
/* IOCONCLKDIV0 */
IOCON_PIO_CLKDIV0);
/* PIO1 PIN17 (coords: 37) is configured as USART0, TXD. */
IOCON_PinMuxSet(IOCON, IOCON_INDEX_PIO1_17, DEBUG_UART_TX);
/* USART0_TXD connect to P1_17 */
SWM_SetMovablePinSelect(SWM0, kSWM_USART0_TXD, kSWM_PortPin_P1_17);
/* USART0_RXD connect to P1_16 */
SWM_SetMovablePinSelect(SWM0, kSWM_USART0_RXD, kSWM_PortPin_P1_16);
/* CLKOUT connect to P0_21 */
SWM_SetMovablePinSelect(SWM0, kSWM_CLKOUT, kSWM_PortPin_P0_21);
/* SCT_PIN0 connect to P0_20 */
SWM_SetMovablePinSelect(SWM0, kSWM_SCT_PIN0, kSWM_PortPin_P0_20);
/* SCT_OUT0 connect to P1_21 */
SWM_SetMovablePinSelect(SWM0, kSWM_SCT_OUT0, kSWM_PortPin_P1_21);
/* SCT_OUT1 connect to P1_20 */
SWM_SetMovablePinSelect(SWM0, kSWM_SCT_OUT1, kSWM_PortPin_P1_20);
/* Disable clock for switch matrix. */
CLOCK_DisableClock(kCLOCK_Swm);
}
最佳答案
请问您想使用SCT实现什么功能?这里有一个SCT 的cookbook, 你可以先参看:
https://www.nxp.com.cn/docs/en/application-note/AN11538.zip
彻底不工作?
你可以打断点和但不执行缩小不工作的范围,定位到底是哪里 ...
|
|