I purchased a development board(845MAX) to evaluate the SCT module
1. Output a 100KHz signal from CLKOUT to P0_21 (which can be measured by the oscilloscope)
2. Route P0_20 as SCT_PIN0 and route to SCT_INMUX 0
3. Short-circuit P0.20 and P0.21
4. Set SCT_OUT0 as the test output 0 (The output waveform can be measured using an oscilloscope by simply matching two values)
5. Set SCT_OUT1 as the test output 1 (set 0 to capture the falling edge of IN0 and set 1 to capture the rising edge of IN0)
(the oscilloscope cannot get any waveform , it is OK after the event was changed to match)
6. SCT_IN0 as a clock doesn't work (either in sampling or asynchronous mode), and SCT doesn't work at all when set( When I use async mode, the debug probe cannot detect the target chip, I erase the flash via ISP and set others clock mode, the IDE can work normally)
I have read the AN11538, INSYNC should be set to 1, so I do.
Plz help me!
Thanks
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_1, kSCTIMER_Counter_U, &SCT0_event[3]);
SCTIMER_SetupOutputClearAction(SCT0, kSCTIMER_Out_1, SCT0_event[3]);
SCTIMER_CreateAndScheduleEvent(SCT0, kSCTIMER_InputRiseEvent, 0, kSCTIMER_Input_1, kSCTIMER_Counter_U, &SCT0_event[4]);
SCTIMER_SetupOutputSetAction(SCT0, kSCTIMER_Out_1, SCT0_event[4]);
SCTIMER_StartTimer(SCT0, kSCTIMER_Counter_U);
}
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);
}
Hello
5. Set SCT_OUT1 as the test output 1 (set 0 to capture the falling edge of IN0 and set 1 to capture the rising edge of IN0)(the oscilloscope cannot get any waveform
>>It seems you use config tool to generate code, so how about create a new project, that just test this function, give a signal to IN0 not from SCT, for example just a high to low to high, check whether the SCT_OUT1 can work well.
Regards,
Alice
The pin configuration is as follows
If there is any problem, could you please point it out
Hello,
You can share your project, I help to check my side, thanks!
Regards,
Alice
Thank you
I think I've found the problem! It is OK now.
INPUTMUX_Init(INPUTMUX) should be executed before the INPUTMUX setting.
CLOCK_EnableClock(kCLOCK_Sct);
CLOCK_EnableClock(kCLOCK_Dma);
In this function: The inputmux clock of sct is enabled.
The SCT INMUX clock is drived by xxx? CLOCK_SCT or CLOCK_SWM ?
Hello ,
I think is CLOCK_SCT, there is no mentioned clearly, while need enable SCT clock then can
control the INPUTMUX register.
Regards,
Alice
I have set SCT_IN4( SCT_CLK == 200kHz ) as the SCT input, the input event can work normally.
The problem may lie in the input Settings for the SCT.
Could you show me an example of SCT input Settings?