LPC824 and RC5 send example from AN11538

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

LPC824 and RC5 send example from AN11538

1,197 Views
JojoS
Contributor II

I'm trying to get this example running, but its not producing the 36 kHz pulses. The samples are different for Keil and other IDE. The Keil example seems to be better, although for LPC812.

I cannot get the event0 triggered with the given config, it should trigger with a dummy input pin, the triggersignal is present. Other events happen, I have checked this with an IRQ Handler for the different events.

Has anybody got this working?

 

 

void SCT_Init(void)
{
Chip_SCT_Init(LPC_SCT); // enable the SCT clock

// Chip_SCT_Config(LPC_SCT, SCT_CONFIG_16BIT_COUNTER); // split timer
LPC_SCT->CONFIG = (LPC_SCT->CONFIG & ~0x00060001) | SCT_CONFIG_16BIT_COUNTER;
LPC_SCT->REGMODE_L = 0x0000; /* L: 2x MATCH, 0x CAPTURE, 3 unused */
LPC_SCT->REGMODE_H = 0x0000; /* L: 2x MATCH, 0x CAPTURE, 3 unused */

Chip_SCT_SetControl(LPC_SCT, SCT_CTRL_PRE_L(SCT_PRESCALER - 1));

Chip_SCT_Output(LPC_SCT, 0 ); // SCT_OUT0 (IR output) is low

Chip_SCT_SetMatchCountL(LPC_SCT, SCT_MATCH_0, SCT_MATCH_DUTY_CYCLE); // 75% of 36 KHz
Chip_SCT_SetMatchReloadL(LPC_SCT, SCT_MATCH_0, SCT_MATCH_DUTY_CYCLE);

Chip_SCT_SetMatchCountL(LPC_SCT, SCT_MATCH_1, SCT_MATCH_PULSE_LENGTH); // 36 KHz
Chip_SCT_SetMatchReloadL(LPC_SCT, SCT_MATCH_1, SCT_MATCH_PULSE_LENGTH);


Chip_SCT_EventState(LPC_SCT, SCT_EVENT_0, ENABLE_ALL_STATES); // event 0 happens in all states
Chip_SCT_EventControl(LPC_SCT, SCT_EVENT_0, (CHIP_SCT_EVENTCTRL_T) ( SCT_EVECTRL_MATCH0 | // MATCHSEL [3:0] = related to match 0
SCT_HEVENT_L | // HEVENT [4] = use L state & match
SCT_OUTSEL_L | // OUTSEL [5] = select input from IOSEL
SCT_IOSEL_RISEIN0 | // IOSEL [9:6] = select input 0
SCT_IOCOND_HIGH | // IOCOND [11:10] = high level
SCT_COMBMODE_OR | // COMBMODE [13:12] = match AND IO condition
SCT_STATELD_0 | // STATELD [14] = STATEV is added to state
SCT_STATEEV_0 | // STATEV [19:15] = no state change
SCT_MATCHMEM | // MATCHMEM [20] = "equal" to match
SCT_DIRECTION )); // DIRECTION[22:21] = direction independent

​

 

 

This is part of the configuration. I have modified SCT_COMBMODE from AND to OR, then I get 36 kHz pulses, but now continous.

When I change to COMBMODE_IO, then it is not triggered. But the IO should be assigned with

Chip_SWM_MovablePinAssign(SWM_SCT_IN0_I,  15);      // CTIN_0 -> PIO0_15 (PWM input) dummy



 
 
 
 
0 Kudos
Reply
4 Replies

1,167 Views
JojoS
Contributor II

The demo code is definitely not working and contains poor bugs:

  • MRT is not running because it is not enabled
  • INMUX configuration is missing, SCT is not triggered
  • Chip_Clock_EnablePeriphClock in main contains wrong arguments and does not enable SWM clock

with fixing this, its working, but there are more flaws:

  • wrong comments
  • NVIC for SCT enabled, but not used
  • LIMIT for event 4 set, but there is no event 4 (leftover from other example)
  • heavy bugs in Chip_GPIO functions: bool used in bit operation, 8 bit mask for 32 bit register

sorry, very poor quality and no updates since many years, no public repo for issue reporting, unusable.

0 Kudos
Reply

1,153 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello JojoS,

Thanks for your sharing, good to hear it can work on your side now. 

 

BR

Alice

1,176 Views
JojoS
Contributor II

Thanks for your reply,

I found that the InputMUX on the LPC824 has to be set, in difference to code for LPC812. I'll have to check what is the reset state for the MUX.

0 Kudos
Reply

1,184 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello ,

So do meaning the demo code without any change can not work on your side?

And what's the problem now?

 

BR

Alice

0 Kudos
Reply