Mike
Give it a few days and if you don't have success with modifying the MCUXpresso examples contact me for access to the uTasker project. I can do this with the following code on the FRDM-KL27Z (in KDS):
QUEUE_HANDLE newSerialID;
PWM_INTERRUPT_SETUP pwm_setup;
unsigned char ucInputBuffer[128];
QUEUE_TRANSFER inputLength;
TTYTABLE tInterfaceParameters;
tInterfaceParameters.Channel = 0;
tInterfaceParameters.ucSpeed = SERIAL_BAUD_115200;
tInterfaceParameters.Config = (CHAR_8 | NO_PARITY | ONE_STOP | USE_XON_OFF | CHAR_MODE | UART_INVERT_TX);
tInterfaceParameters.Rx_tx_sizes.RxQueueSize = 64;
tInterfaceParameters.Rx_tx_sizes.TxQueueSize = 512;
tInterfaceParameters.Task_to_wake = OWN_TASK;
SerialID = fnOpen(TYPE_TTY, FOR_I_O, ptrInterfaceParameters);
fnDriver(SerialID, (TX_ON | RX_ON), 0);
pwm_setup.int_type = PWM_INTERRUPT;
pwm_setup.pwm_mode = (PWM_SYS_CLK | PWM_PRESCALER_16 | PWM_EDGE_ALIGNED);
pwm_setup.int_handler = 0;
pwm_setup.pwm_frequency = PWM_FREQUENCY(1000000, 16);
pwm_setup.pwm_reference = (_TIMER_2 | 0);
pwm_setup.pwm_mode |= (PWM_OPTION_MODULATE_LPUART0);
pwm_setup.pwm_value = _PWM_TENTH_PERCENT(706, pwm_setup.pwm_frequency);
fnWrite(SerialID, "Hello, World!!", 14);
while (inputLength = fnRead(SerialID, ucInputBuffer, sizeof(ucInputBuffer))) {
fnWrite(SerialID, ucInputBuffer, inputLength);
}
This configures the LPUART (change the channel to 1 to 2 for LPUART1 or UART2 instead of LPUART0) with the specified settings. Note that I invert the LPUART output for modulation mode (option). To use DMA the optional UART_TX_DMA is set.
Then a TPM is configured to modulate the LPUART Tx at 1MHz (70%) - TPM2 channel 0. The frequency, mark-space-ratio or other TPM/channels can be configured by changing the values (or other LPUARTs modulated).
Then I show sending data out, plus receiving data (and echoing it back).
That is all that is needed so I don't think that it can be done much simpler (with this flexibility).
I also attach a FRDM-KL27Z binary that shows this in operation on LPUART0 (the one connected to the VCOM). If you type something in it will echo it (and the modulated signal can be measured on J26). In addition I put a USB-CDC interface on the USB with a command line menu to allow debugging and various other monitoring/tests. In the uTasker project adding the USB-CDC command line interface costs just three lines of code effort for the programmer:
#define USB_INTERFACE
#define USB_DEVICE_SUPPORT
#define USE_USB_CDC
(and optionally #define USB_CDC_COUNT 2 [1..6 possible] for multiple USB-CDC connections at the same time).
A further advantage is that if you want to do the same thing on other Kinetis parts or boards you don't need to set up different projects and use different libraries and interfaces - you can just select the board (eg. FRDM_K64F instead of FRDM_KL27Z) and it already works there instead.
I don't think it can be much simpler than this....
Regards
Mark