This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hello Amit!
In my last post, you send to me working UART uDMA code, which receive Data from PC.
Can you a little bit more explain, how you tested/send data to Launchpad?
Today I'm all day trying it, sending longer than 16 characters data via Putty program or Terminal v1.9b, buffers still empty..
#include <stdint.h> #include <stdbool.h> #include "inc/hw_ints.h" #include "inc/hw_memmap.h" #include "inc/hw_types.h" #include "inc/hw_uart.h" #include "driverlib/fpu.h" #include "driverlib/gpio.h" #include "driverlib/interrupt.h" #include "driverlib/pin_map.h" #include "driverlib/rom.h" #include "driverlib/sysctl.h" #include "driverlib/systick.h" #include "driverlib/uart.h" #include "driverlib/udma.h" #include "utils/cpu_usage.h" #include "utils/uartstdio.h" #include "utils/ustdlib.h" //***************************************************************************** //***************************************************************************** #if defined(ewarm) #pragma data_alignment=1024 uint8_t ui8ControlTable[1024]; #elif defined(ccs) #pragma DATA_ALIGN(ui8ControlTable, 1024) uint8_t ui8ControlTable[1024]; #else uint8_t ui8ControlTable[1024] __attribute__ ((aligned(1024))); #endif #define UART_TXBUF_SIZE 16 #define UART_RXBUF_SIZE 16 static uint8_t g_pui8TxBuf[UART_TXBUF_SIZE]; static uint8_t g_pui8RxPing[UART_RXBUF_SIZE]; static uint8_t g_pui8RxPong[UART_RXBUF_SIZE]; // Error counter static uint32_t g_ui32DMAErrCount = 0; // Transfer counters static uint32_t g_ui32RxPingCount = 0; static uint32_t g_ui32RxPongCount = 0; volatile int UARTIntHitsCounter = 0; // uDMA control table aligned to 1024-byte boundary #pragma DATA_ALIGN(ucControlTable, 64) uint8_t ucControlTable[64]; void uDMAErrorHandler(void) { uint32_t ui32Status; ui32Status = ROM_uDMAErrorStatusGet(); if(ui32Status) { ROM_uDMAErrorStatusClear(); g_ui32DMAErrCount++; } } // UART interrupt handler. Called on completion of uDMA transfer void UART0IntHandler(void) { uint32_t ui32Status; uint32_t ui32Mode; ui32Status = ROM_UARTIntStatus(UART0_BASE, 1); ROM_UARTIntClear(UART0_BASE, ui32Status); UARTIntHitsCounter++; ui32Mode = ROM_uDMAChannelModeGet(UDMA_CHANNEL_UART0RX | UDMA_PRI_SELECT); if(ui32Mode == UDMA_MODE_STOP) { g_ui32RxPingCount++; ROM_uDMAChannelTransferSet(UDMA_CHANNEL_UART0RX | UDMA_PRI_SELECT, UDMA_MODE_PINGPONG, (void *)(UART0_BASE + UART_O_DR), g_pui8RxPing, sizeof(g_pui8RxPing)); } ui32Mode = ROM_uDMAChannelModeGet(UDMA_CHANNEL_UART0RX | UDMA_ALT_SELECT); if(ui32Mode == UDMA_MODE_STOP) { g_ui32RxPongCount++; ROM_uDMAChannelTransferSet(UDMA_CHANNEL_UART0RX | UDMA_ALT_SELECT, UDMA_MODE_PINGPONG, (void *)(UART0_BASE + UART_O_DR), g_pui8RxPong, sizeof(g_pui8RxPong)); } if(!ROM_uDMAChannelIsEnabled(UDMA_CHANNEL_UART0TX)) { ROM_uDMAChannelTransferSet(UDMA_CHANNEL_UART0TX | UDMA_PRI_SELECT, UDMA_MODE_BASIC, g_pui8TxBuf, (void *)(UART0_BASE + UART_O_DR), sizeof(g_pui8TxBuf)); ROM_uDMAChannelEnable(UDMA_CHANNEL_UART0TX); } } // Initialize UART uDMA transfer void InitUART1Enable(void) { ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); // Enable UART1 and make sure it can run while the CPU sleeps ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); ROM_SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_UART0); ROM_GPIOPinConfigure(GPIO_PA0_U0RX); ROM_GPIOPinConfigure(GPIO_PA1_U0TX); // Configure and enable the UART with DMA ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); ROM_UARTConfigSetExpClk(UART0_BASE, ROM_SysCtlClockGet(), 115200, UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE); ROM_UARTFIFOLevelSet(UART0_BASE, UART_FIFO_TX4_8, UART_FIFO_RX4_8); ROM_UARTEnable(UART0_BASE); ROM_UARTDMAEnable(UART0_BASE, UART_DMA_RX); ROM_IntEnable(INT_UART0); // Receive channel setup for ping and pong ROM_uDMAChannelAttributeDisable(UDMA_CHANNEL_UART0RX, UDMA_ATTR_ALTSELECT | UDMA_ATTR_USEBURST | UDMA_ATTR_HIGH_PRIORITY | UDMA_ATTR_REQMASK); ROM_uDMAChannelAttributeEnable(UDMA_CHANNEL_UART0RX, UDMA_ATTR_ALTSELECT | UDMA_ATTR_USEBURST | UDMA_ATTR_HIGH_PRIORITY | UDMA_ATTR_REQMASK); ROM_uDMAChannelControlSet(UDMA_CHANNEL_UART0RX | UDMA_PRI_SELECT, UDMA_SIZE_8 | UDMA_SRC_INC_NONE | UDMA_DST_INC_8 | UDMA_ARB_4); ROM_uDMAChannelControlSet(UDMA_CHANNEL_UART0RX | UDMA_ALT_SELECT, UDMA_SIZE_8 | UDMA_SRC_INC_NONE | UDMA_DST_INC_8 | UDMA_ARB_4); ROM_uDMAChannelTransferSet(UDMA_CHANNEL_UART0RX | UDMA_PRI_SELECT, UDMA_MODE_PINGPONG, (void *)(UART0_BASE + UART_O_DR), g_pui8RxPing, sizeof(g_pui8RxPing)); ROM_uDMAChannelTransferSet(UDMA_CHANNEL_UART0RX | UDMA_ALT_SELECT, UDMA_MODE_PINGPONG, (void *)(UART0_BASE + UART_O_DR), g_pui8RxPong, sizeof(g_pui8RxPong)); // Enable both channels ROM_uDMAChannelEnable(UDMA_CHANNEL_UART0RX); } int main(void) { volatile uint32_t ui32Loop; ROM_FPULazyStackingEnable(); ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); ROM_SysCtlPeripheralClockGating(true); // GPIO setup for LEDs ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2); // Enable uDMA ROM_SysCtlPeripheralReset(SYSCTL_PERIPH_UDMA); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UDMA); ROM_SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_UDMA); //ROM_IntEnable(INT_UDMAERR); ROM_uDMAEnable(); ROM_uDMAControlBaseSet(ucControlTable); // Initialize the uDMA/UART InitUART1Enable(); while(1) { if(UARTIntHitsCounter > 0) { GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, GPIO_PIN_2); SysCtlDelay(SysCtlClockGet() / 20 / 3); GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 0); SysCtlDelay(SysCtlClockGet() / 20 / 3); } } }
at startup_ccs
extern void uDMAErrorHandler(void);
extern void UART0IntHandler(void);
IntDefaultHandler, // GPIO Port E
UART0IntHandler, // UART0 Rx and Tx
uDMAErrorHandler, // uDMA Error
IntDefaultHandler, // uDMA Software Transfer uDMAIntHandler
Hello Gytis,
To test the code, I used the TeraTerm to send the characters. Did the original code I sent work?
Regards
Amit
This is your original code and I trying make it work... I tryed and with TeraTerm program, still nothing, g_pui8RxPing & g_pui8RxPong buffers are empty after sending even more than 16 characters. And I can see, that interrupt was never fired up..
My launchpad work good, original uDMA_demo example work too..
Hello Gytis,
I compared the C source file in this post to he C source file I had sent earlier. There are changes
1. UART0 is now being used?
2. You have enabled Alternate Channel Control Structure to be used for the first transfer which is going to be Ping (or Primary Control Structure)?
ROM_uDMAChannelAttributeEnable(UDMA_CHANNEL_UART0RX,
UDMA_ATTR_ALTSELECT | UDMA_ATTR_USEBURST |
UDMA_ATTR_HIGH_PRIORITY |
UDMA_ATTR_REQMASK);
Regards
Amit
Yea,
Sorry, I sent to you wrong code, in this one, I try all the different kind conbinations to enable UART uDMA..
Im trying your to me send code, nothing change!!! ( its with ROM_uDMAChannelAttributeDisable and UART1 )
So, how I try your code:
1) I putt your code to CCS, press Build Debug button. I get 0 warnings, 0 errors, 0 others!
2) I debug your code, enerything Good! Like always, press Resume button, code start work..
3) Turn on Tera Term program, select Serial -- > Port: COM4: Stellaris Virtual Serial port (its my launchpad port)
4) Now in black window, I go up to setup --> Serial setup --> changes only baud rate to 115200.
5) In black window write 16 "FFFFFFFFFFFFFFFF" characters, or more, in this case I try a lot different combinations...
6) In CCS, then I press suspend button, go to memory browser, check g_pui8RxPong g_pui8RxPing values and its always empty...
I tryed in different methods, sometimes first modify TeraTerm, aftern that start code working and etc..
Hello Gytis,
I will change the application code to do the same with UART0 so that you can use the TeraTerm without making any wiring changes to the LaunchPad.
Also do make sure that in the CCS window the peripheral is not selected for Memory Browser.
Regards,
Amit
@ Amit - You've gone (again) above/beyond w/this fellow. Yet - while much valuable UART Set-Up/Config is likely to result - the (poorly considered) Subject/Title by poster will mean this will (likely) be a one-time viewed thread - unlikely to "register" upon any "UART" search. "UART Set-Up detail" - imho - seems vastly better subject/title - raises the odds for future, "UART seekers." That is a forum goal - is it not?
As this purports to be, "Quick Question" - cannot imagine the size, twists, indirections of one, "not so quick..."
cb1_mobile said:twists, indirections of one, "not so quick..."
I bypassed at first time... privacy need a concern, may be it was a Secret love declaration ;)
Mon Ami,
You may consider brief "cut back" in your read/review of romance novellas - popular (I'm told) your, "neck of the woods." Strictly ARM & general EE issues "flow w/some regularity" - fine pen - this reporter... (don't you dare)
Might such posting violate the "quickness" of poster's question? (that "quick" title still casts zero light upon what went on - this long (surely not quick) thread...)