LPC-link2 external trigger for HSADC using SCT event

cancel
Showing results for 
Search instead for 
Did you mean: 

LPC-link2 external trigger for HSADC using SCT event

316 Views
chuangnan_wang
Contributor I

I am currently using the LPX-link2 for signal collection. And would like to add a external trigger feature. I read the post LPC-link2 external trigger for HSADC jeremyzhouravithakur and follow the instruction, I have done bellowing:

1. import the zip file and change the main function into jeremyzhou's code, then build and run it in debug mode
2. trigger it using a 3 V DC signal, with half second on and half second off, but the LED not turn on
3. check P1_13 by using GPIO mode, which shows that is the correct pin.


I am a bit confused and will be very appreciate if anyone give a clue in how to make it work. 

Chuangnan

Tags (2)
0 Kudos
6 Replies

190 Views
jeremyzhou
NXP TechSupport
NXP TechSupport

Hi Chuangnan Wang,

Thanks for your clarification.
After having a brief review of my code, I've not found anything wrong with it.
So I'd like to suggest you refer to the application note: AN11538 SCTimer/PWM Cookbook, there's an example: RC5 receiving which is similar to your implementation, maybe you can refer to its demo code.

Have a great day,
TIC

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

190 Views
chuangnan_wang
Contributor I

Hi jeremyzhou‌,

Thanks a lot for the help. I will try it. 

Best regards

Chuangnan

0 Kudos

190 Views
jeremyzhou
NXP TechSupport
NXP TechSupport

Hi Chuangnan Wang,

Thank you for your interest in NXP Semiconductor products and for the opportunity to serve you.
Actually, I'm still not clear with your question, whether you can introduce it in detail.

Have a great day,
TIC

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

190 Views
chuangnan_wang
Contributor I

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:

/*
===============================================================================
 Name : ctin_test.c
 Author : $(author)
 Version :
 Copyright : $(copyright)
 Description : main definition
===============================================================================
*/
#include "chip.h"
#include "board.h"
// TODO: insert other include files here
// TODO: insert other definitions and declarations here
#define SCT_MATCHSEL0 (0 << 0) // Match register 0
#define SCT_HEVENT (0 << 4)
#define SCT_OUTSEL_IN (0 << 5) // Pin selected by IOSEL is input
#define SCT_IOSEL (4 << 6) // Input 4 = ctin4
#define SCT_IOCOND_RISE (1 << 10) // Trigger on rising edge on input
#define SCT_IOCOND_HIGH (1 << 10) // Trigger on input level high
#define SCT_COMBMODE_IO (2 << 12) // Only input transition to cause event
#define SCT_STATELD_NONE (1 << 14) // Use no states
#define SCT_STATEV_NONE (0 << 15) // Use no states
#define SCT_STOP_L (1 << 1) // Stop = 1
#define SCT_CLRCTR_L (1 << 3) // Clear unified counter
#define SCT_BIDIR_L (0 << 4) // Set counters to count up
#define SCT_PRE_L (0 << 5) // Set pre-scaler value to 0
#define SCT_HALT_CLR (1 << 2) // Clear HALT
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);
// TODO: insert code here
 Chip_Clock_EnableOpts(CLK_MX_SCU, true, true, 1);
 
 
 //Set pin2_13 as ctin4. ctin4 is the default input to sct4
 Chip_SCU_PinMux(2, 13, SCU_MODE_PULLDOWN, SCU_MODE_FUNC1);
//SCT outputs are ORed with timer match outputs by default
 //Setting this bit disables this
 //LPC_CREG->CREG6 = (1 << 4);
//Enable SCT clock
 Chip_SCT_Init(LPC_SCT);
 Chip_RGU_TriggerReset(RGU_SCT_RST);
 while(Chip_RGU_InReset(RGU_SCT_RST)){} //do nothing while in reset
//Configure SCT to run on bus clock, enable unify and INSYNCn bit is set
 //by default
 Chip_SCT_Config(LPC_SCT, SCT_CONFIG_32BIT_COUNTER |
 SCT_CONFIG_CLKMODE_BUSCLK);
LPC_SCT->EVENT[0].STATE = 0x00000001; // Enable event 0
 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->INPUT == 0){} //works, led is turned on
while(LPC_SCT->EVFLAG == 0){} //does not work, led is off
//while (LPC_SCT->INPUT == 0){} //works, led is turned on
Board_LED_Set(0, true); // can replace this with a write to the output register
// Force the counter to be placed into memory
 volatile static int i = 0 ;
 // Enter an infinite loop, just incrementing a counter
 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 

0 Kudos

190 Views
jeremyzhou
NXP TechSupport
NXP TechSupport

Hi Chuangnan Wang,

Thanks for your reply.
The CTIN_4 is assigned to P2_13 pin, not the P1_13, please check it.

pastedImage_1.png

Have a great day,
TIC

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

190 Views
chuangnan_wang
Contributor I

Hi jeremyzhou‌,

Sorry for the confusing, I do mean pin2_13, and I check it on GPIO1_13. 

Best regards

Chuangnan 

0 Kudos