Getting SCT to trigger ADC

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Getting SCT to trigger ADC

1,570 Views
gregwilson-lind
Contributor II

I'm trying to use SCT2 to trigger the ADC and am having no luck. Here is the initialization code that I'm using:

// LPC_SCT2->CONFIG |= 0;               // 16-bit timer
LPC_SCT2->CONFIG |= (1 << 18);     // 16-bit timer, auto limit high
LPC_SCT2->CTRL_H |= (64 << 5);     // Pre-scaler & halt H timer
// LPC_SCT2->LIMIT_H |= (1 << 0);    // Event 0 limit high

LPC_SCT2->MATCHREL[0].H = 5000 - 1;    // match 0 @ 200 Hz = 5 msec, toggle will make it 100 Hz, 10ms
LPC_SCT2->MATCH[0].H = 5000 - 1;           // match 0 @ 200 Hz = 5 msec

LPC_SCT2->EVENT[0].STATE = 0xFFFF;    // event 0 happens in all states
LPC_SCT2->EVENT[0].CTRL = (0 << 0) |     // Match 0
                                                    (1 << 4) |     // High counter
                                                    (1 << 12);    // match condition only

LPC_SCT2->EVEN = (1 << 0); // enable event 0 interrupt
NVIC_EnableIRQ(SCT2_IRQn);

LPC_SCT2->OUT[3].SET = (1 << 0);             // event 0 will set SCT2_OUT3
LPC_SCT2->OUT[3].CLR = (1 << 0);             // event 0 will clear SCT2_OUT3
LPC_SCT2->RES = (3 << 6);                         // output 3 toggles on conflict

LPC_SCT2->OUT[0].SET = (1 << 0);             // event 0 will set SCT2_OUT0
LPC_SCT2->OUT[0].CLR = (1 << 0);             // event 0 will clear SCT2_OUT0
LPC_SCT2->RES = (3 << 6) | (3 << 0);          // output 0 toggles on conflict
// Output SCT_OUT0 on PIO2_3, pin 76
/* SCT1_OUT0, SCT1_OUT1, SCT1_OUT2, SCT2_OUT0 */
LPC_SWM->PINASSIGN[8] = 0x43FFFFFFUL;

LPC_SCT2->CTRL_H &= ~SCT_CTRL_HALT_L; // un-halt

// after everything is setup, enable the ADC
Chip_ADC_SetupSequencer(LPC_ADC0, ADC_SEQA_IDX,
                                                (ADC_SEQ_CTRL_CHANSEL(BOARD_ADC_TEMP_INT) |
                                                 ADC_SEQ_CTRL_CHANSEL(BOARD_ADC_TEMP_TOP) |
                                                 ADC_SEQ_CTRL_CHANSEL(BOARD_ADC_36V_POWERSUPPLY) |
                                                 ADC_SEQ_CTRL_CHANSEL(BOARD_ADC_36V_BATTERY) |
                                                 ADC_SEQ_CTRL_CHANSEL(BOARD_ADC_MOTOR_CURRENT) |
                                                 ADC0_SEQ_CTRL_HWTRIG_SCT2_OUT3 |   // User SCT2 OUT[3] for trigger
                                                 ADC_SEQ_CTRL_MODE_EOS |
                                                 ADC_SEQ_CTRL_SEQ_ENA));

I'm getting the interrupt for Event[0] but it seems that OUT[3] is not toggling. I can't look at OUT[3], the SWM only allows SCT2_OUT[0-2] to go to pins, and the ADC only allows SCT2_OUT[3-4] to trigger, so I set up OUT[0] to operate in the same way and I don't get an output for OUT[0].

I'm obviously missing something, if any one can help me out I would appreciate it.

Labels (1)
Tags (2)
0 Kudos
Reply
3 Replies

1,250 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Greg Wilson-Lindberg,

Thank you for your interest in NXP Semiconductor products and 
for the opportunity to serve you.

I was wondering if you can tell me which type of MCU you used.

Have a great day,
TIC

 

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

0 Kudos
Reply

1,249 Views
gregwilson-lind
Contributor II

Hi Jeremy,

I'm sorry, it's running on an LPC1519.

Regards,

Greg Wilson-Lindberg

Principal Firmware Engineer | Sakura Finetek USA, Inc.

1750 W 214th Street | Torrance, CA 90501 | U.S.A.

T: +1 310 783 5075

F: +1 310 618 6902 | E: gwilson@sakuraus.com<mailto:gwilson@sakuraus.com>

www.sakuraus.com<http://www.sakuraus.com>;

0 Kudos
Reply

1,249 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Greg Wilson-Lindberg,

Thanks for your reply.

After have a brief of review, I don't find any obvious errors.

So I'd highly recommend you to assign the SCT2_OUT3 to PIO0_6, then you can display the SCT2_OUT3 in OSC.

It's helpful to figure out the root cause of the issue.

pastedImage_1.png

Have a great day,
TIC

 

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

0 Kudos
Reply