Hi jeremyzhou,
Thanks a lot for the reply.
I currently have a small piece of code that can do data collection using LPC-link2 in software trigger mode. I would like to sync this to function generator with a external trigger signal. Then I found your suggestion of using COUNT_n as the trigger, for instance CTOUT_0. The SCT can detect external signal of I/O as event, then the event can arise the SCT_CTOUT_n output high or low level, in this postLPC-link2 external trigger for HSADC. I follow the instruction, but I may not setup correctly and cannot get it to work. Below is the code from the previous post:
#include "chip.h"
#include "board.h"
#define SCT_MATCHSEL0 (0 << 0)
#define SCT_HEVENT (0 << 4)
#define SCT_OUTSEL_IN (0 << 5)
#define SCT_IOSEL (4 << 6)
#define SCT_IOCOND_RISE (1 << 10)
#define SCT_IOCOND_HIGH (1 << 10)
#define SCT_COMBMODE_IO (2 << 12)
#define SCT_STATELD_NONE (1 << 14)
#define SCT_STATEV_NONE (0 << 15)
#define SCT_STOP_L (1 << 1)
#define SCT_CLRCTR_L (1 << 3)
#define SCT_BIDIR_L (0 << 4)
#define SCT_PRE_L (0 << 5)
#define SCT_HALT_CLR (1 << 2)
void SCT_IRQHandler(void) {
Board_LED_Set(0, true);
Chip_SCT_ClearEventFlag(LPC_SCT, SCT_EVT_0);
}
int main(void) {
SystemCoreClockUpdate();
Chip_Clock_EnableOpts(CLK_MX_GPIO, true, true, 1);
Board_Init();
Board_LED_Set(0, false);
Chip_Clock_EnableOpts(CLK_MX_SCU, true, true, 1);
Chip_SCU_PinMux(2, 13, SCU_MODE_PULLDOWN, SCU_MODE_FUNC1);
Chip_SCT_Init(LPC_SCT);
Chip_RGU_TriggerReset(RGU_SCT_RST);
while(Chip_RGU_InReset(RGU_SCT_RST)){}
Chip_SCT_Config(LPC_SCT, SCT_CONFIG_32BIT_COUNTER |
SCT_CONFIG_CLKMODE_BUSCLK);
LPC_SCT->EVENT[0].STATE = 0x00000001;
LPC_SCT->EVENT[0].CTRL = SCT_MATCHSEL0 | SCT_OUTSEL_IN | SCT_IOSEL |
SCT_IOCOND_HIGH | SCT_COMBMODE_IO |
SCT_STATELD_NONE | SCT_STATEV_NONE;
Chip_SCT_EnableEventInt(LPC_SCT, SCT_EVT_0);
Chip_SCT_ClearEventFlag(LPC_SCT, SCT_EVT_0);
Chip_SCT_ClearControl(LPC_SCT, SCT_HALT_CLR);
while(LPC_SCT->EVFLAG == 0){}
Board_LED_Set(0, true);
volatile static int i = 0 ;
while(1) {
i++ ;
}
return 0 ;
}
I using the pin1_13 and input the 3 volt step signal, but the SCT event does not triggered. I am very grateful to get any suggestion / clue that what I have done wrong.
Best regards
Chuangnan