Scott
Here are three references:
1. Generating a square wave output from PIT (or two in complimentary pair)
2. Decoding RC5 IR protocol (8x oversampling of pulses to a buffer for subsequent analysis)
3. Port mirroring (toggling other ports based on a signal on an input port).
Regards
Mark
1. (method integrated in uTasker PIT interface)
void fnPitFreqGen(void)
{
PIT_SETUP pit_setup; // PIT interrupt configuration parameters
pit_setup.int_type = PIT_INTERRUPT;
pit_setup.int_handler = 0; // no interrupt due to DMA
pit_setup.ucPIT = 0; // use PIT0
pit_setup.count_delay = PIT_US_DELAY(1); // 1us period (for 500kHz square wave)
pit_setup.mode = (PIT_PERIODIC | PIT_OUTPUT_DMA_TRIG); // periodic with DMA trigger to control a port toggle
pit_setup.ulPortBits = (PORTA_BIT1 | PORTA_BIT2); // toggle PTA1 and PTA2 on each PIT trigger
pit_setup.ucPortRef = PORTA;
fnConfigureInterrupt((void *)&pit_setup); // configure PIT
}
2. (uses uTasker PIT interface and DMA buffer interface)
#define BIT_LENGTH 1800
#define SAMPLES_PER_BIT 8
#define NR_OF_RC5_BYTES 14
#define RC5_SAMPLES (NR_OF_RC5_BYTES * SAMPLES_PER_BIT)
static unsigned long ulSampleBuffer[RC5_SAMPLES] = {0};
void fnReadRC5(void)
{
PIT_SETUP pit_setup;
pit_setup.int_type = PIT_INTERRUPT;
pit_setup.int_handler = 0;
pit_setup.ucPIT = 1;
pit_setup.count_delay = PIT_US_DELAY(BIT_LENGTH / SAMPLES_PER_BIT);
pit_setup.mode = (PIT_PERIODIC);
pit_setup.ucPortRef = PORTC;
fnConfigureInterrupt((void *)&pit_setup);
fnConfigDMA_buffer(pit_setup.ucPIT, (DMAMUX0_DMA0_CHCFG_SOURCE_PIT0 + pit_setup.ucPIT), sizeof(ulSampleBuffer), (unsigned long *)(GPIO_BLOCK + (0x040 * pit_setup.ucPIT) + 0x010), ulSampleBuffer, (DMA_DIRECTION_INPUT | DMA_LONG_WORDS | DMA_NO_MODULO), DMA_handler, 2);
fnDMA_BufferReset(pit_setup.ucPIT, DMA_BUFFER_START);
}
static void DMA_handler(void)
{
fnInterruptMessage(TaskToWake, REMOTE_CONTROL_EVENT);
}
3. (uses uTasker port interrupt/DMA interface and DMA buffer interface)
static void fnPortMirrors(void)
{
static const unsigned long ulOutput = (PORTC_BIT16 | PORTC_BIT17);
INTERRUPT_SETUP interrupt_setup;
interrupt_setup.int_type = PORT_INTERRUPT;
interrupt_setup.int_port = PORTB;
interrupt_setup.int_port_bits = PORTB_BIT16;
interrupt_setup.int_port_sense = (IRQ_BOTH_EDGES | PULLUP_ON | PORT_DMA_MODE | PORT_KEEP_PERIPHERAL);
interrupt_setup.int_handler = 0;
fnConfigDMA_buffer(9, DMAMUX0_CHCFG_SOURCE_PORTB, sizeof(ulOutput), (void *)&ulOutput, (void *)&(((GPIO_REGS *)GPIOC_ADD)->PTOR), (DMA_FIXED_ADDRESSES | DMA_LONG_WORDS), 0, 0);
}