/************************************************************************************************** Filename: SimpleBLEPeripheral_Main.c Revised: $Date: 2010-07-06 15:39:18 -0700 (Tue, 06 Jul 2010) $ Revision: $Revision: 22902 $ Description: This file contains the main and callback functions for the Simple BLE Peripheral sample application. Copyright 2010 - 2011 Texas Instruments Incorporated. All rights reserved. IMPORTANT: Your use of this Software is limited to those specific rights granted under the terms of a software license agreement between the user who downloaded the software, his/her employer (which must be your employer) and Texas Instruments Incorporated (the "License"). You may not use this Software unless you agree to abide by the terms of the License. The License limits your use, and you acknowledge, that the Software may not be modified, copied or distributed unless embedded on a Texas Instruments microcontroller or used solely and exclusively in conjunction with a Texas Instruments radio frequency transceiver, which is integrated into your product. Other than for the foregoing purpose, you may not use, reproduce, copy, prepare derivative works of, modify, distribute, perform, display or sell this Software and/or its documentation for any purpose. YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE PROVIDED �AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS. Should you have any questions regarding your right to use this Software, contact Texas Instruments Incorporated at www.TI.com. **************************************************************************************************/ /************************************************************************************************** * Includes **************************************************************************************************/ /* Hal Drivers */ #include "hal_types.h" #include "hal_key.h" #include "hal_timer.h" #include "hal_drivers.h" #include "hal_led.h" #include "hal_lcd.h" #include "hal_uart.h" # define UART0TX_DMA 1 #define NO_OSAL_LAYER # if defined (NO_OSAL_LAYER) # include "hal_dma.h" extern halDMADesc_t dmaCh1Tx; extern halDMADesc_t dmaCh1TxDummy; # endif /* OSAL */ #include "OSAL.h" #include "OSAL_Tasks.h" #include "OSAL_PwrMgr.h" #include "osal_snv.h" #include "OnBoard.h" /************************************************************************************************** * FUNCTIONS **************************************************************************************************/ /************************************************************************************************** * @fn main * * @brief Start of application. * * @param none * * @return none ************************************************************************************************** */ int main(void) { /* Initialize hardware */ HAL_BOARD_INIT(); // Initialize board I/O InitBoard( OB_COLD ); /* Initialze the HAL driver */ HalDriverInit(); /* Initialize NV system */ osal_snv_init(); /* Initialize LL */ /* Initialize the operating system */ osal_init_system(); /* Enable interrupts */ HAL_ENABLE_INTERRUPTS(); // Final board initialization InitBoard( OB_READY ); uint8 status; halUARTCfg_t uart_config; halUARTBufControl_t TxBufCtrl, RxBufCtrl; # define UART_BUF_LEN 10 # define CDI_PORT HAL_UART_PORT_0 TxBufCtrl.maxBufSize = UART_BUF_LEN; RxBufCtrl.maxBufSize = UART_BUF_LEN; RxBufCtrl.pBuffer = osal_mem_alloc(UART_BUF_LEN); uart_config.configured = TRUE; uart_config.baudRate = HAL_UART_BR_57600; uart_config.flowControl = HAL_UART_FLOW_OFF; uart_config.flowControlThreshold = 0x00; uart_config.idleTimeout = 6; uart_config.rx = RxBufCtrl; uart_config.tx = TxBufCtrl; uart_config.intEnable = FALSE; uart_config.callBackFunc = NULL;//(halUARTCBack_t) HalUARTCback; status = HalUARTOpen(CDI_PORT, &uart_config); /*if (status == HAL_UART_SUCCESS) { HalLcdWriteString( "OPEN P0 OK", HAL_LCD_LINE_1 ); } else { HalLcdWriteString( "OPEN P0 ERR", HAL_LCD_LINE_1 ); }*/ # if defined (NO_OSAL_LAYER) char tempuartwritetext[20]= "0123456789ABCDEFGHIJ"; halDMADesc_t *tempdmaCh1Tx= &dmaCh1Tx; HAL_DMA_SET_DEST( tempdmaCh1Tx, 0x70C1 ); // Using the length field to determine how many bytes to transfer. HAL_DMA_SET_VLEN( tempdmaCh1Tx, HAL_DMA_VLEN_USE_LEN ); // One byte is transferred each time. HAL_DMA_SET_WORD_SIZE( tempdmaCh1Tx, HAL_DMA_WORDSIZE_BYTE ); // The source address is incremented by 1 byte after each transfer. HAL_DMA_SET_SRC_INC( tempdmaCh1Tx, HAL_DMA_SRCINC_1 ); // The destination address is constant - the Tx Data Buffer. HAL_DMA_SET_DST_INC( tempdmaCh1Tx, HAL_DMA_DSTINC_0 ); // The DMA Tx done is serviced by ISR in order to maintain full thruput. //HAL_DMA_SET_IRQ( tempdmaCh1Tx, HAL_DMA_IRQMASK_ENABLE ); // Xfer all 8 bits of a byte xfer. HAL_DMA_SET_M8( tempdmaCh1Tx, HAL_DMA_M8_USE_8_BITS ); // DMA has second highest priority for memory access. HAL_DMA_SET_PRIORITY( tempdmaCh1Tx, HAL_DMA_PRI_GUARANTEED); HAL_DMA_SET_LEN(tempdmaCh1Tx,sizeof(tempuartwritetext)); HAL_DMA_SET_SOURCE(tempdmaCh1Tx,tempuartwritetext); HAL_DMA_SET_TRIG_MODE( tempdmaCh1Tx, HAL_DMA_TMODE_BLOCK);//HAL_DMA_TMODE_BLOCK_REPEATED);//HAL_DMA_TMODE_SINGLE_REPEATED );//HAL_DMA_TMODE_BLOCK HAL_DMA_SET_TRIG_SRC( tempdmaCh1Tx, HAL_DMA_TRIG_NONE);//HAL_DMA_TRIG_UTX0); HAL_DMA_CLEAR_IRQ(UART0TX_DMA); //if (DMAARM & (0x01 << UART0TX_DMA))//HAL_DMA_CH_ARMED (1) == 1) while(1) //do { while ((DMAARM & (0x01 << UART0TX_DMA)) == 0)//HAL_DMA_CH_ARMED (1) == 1) { //HAL_DMA_ARM_CH(UART0TX_DMA); DMAARM = DMAARM | (0x01 << UART0TX_DMA); asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop"); } HAL_DMA_MAN_TRIGGER(UART0TX_DMA); //HAL_DMA_SET_TRIG_SRC( tempdmaCh1Tx,HAL_DMA_TRIG_UTX0); asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop"); }//while (0); while(1); #else #if defined ( POWER_SAVING ) osal_pwrmgr_device( PWRMGR_BATTERY ); #endif /* Start OSAL */ osal_start_system(); // No Return from here # endif return 0; } /************************************************************************************************** CALL-BACKS **************************************************************************************************/ /************************************************************************************************* **************************************************************************************************/
/************************************************************************************************** Filename: SimpleBLEPeripheral_Main.c Revised: $Date: 2010-07-06 15:39:18 -0700 (Tue, 06 Jul 2010) $ Revision: $Revision: 22902 $ Description: This file contains the main and callback functions for the Simple BLE Peripheral sample application. Copyright 2010 - 2011 Texas Instruments Incorporated. All rights reserved. IMPORTANT: Your use of this Software is limited to those specific rights granted under the terms of a software license agreement between the user who downloaded the software, his/her employer (which must be your employer) and Texas Instruments Incorporated (the "License"). You may not use this Software unless you agree to abide by the terms of the License. The License limits your use, and you acknowledge, that the Software may not be modified, copied or distributed unless embedded on a Texas Instruments microcontroller or used solely and exclusively in conjunction with a Texas Instruments radio frequency transceiver, which is integrated into your product. Other than for the foregoing purpose, you may not use, reproduce, copy, prepare derivative works of, modify, distribute, perform, display or sell this Software and/or its documentation for any purpose. YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE PROVIDED �AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS. Should you have any questions regarding your right to use this Software, contact Texas Instruments Incorporated at www.TI.com. **************************************************************************************************/ /************************************************************************************************** * Includes **************************************************************************************************/ /* Hal Drivers */ #include "hal_types.h" #include "hal_key.h" #include "hal_timer.h" #include "hal_drivers.h" #include "hal_led.h" #include "hal_lcd.h" #include "hal_uart.h" # define UART0TX_DMA 1 #define NO_OSAL_LAYER # if defined (NO_OSAL_LAYER) # include "hal_dma.h" extern halDMADesc_t dmaCh1Tx; extern halDMADesc_t dmaCh1TxDummy; # endif /* OSAL */ #include "OSAL.h" #include "OSAL_Tasks.h" #include "OSAL_PwrMgr.h" #include "osal_snv.h" #include "OnBoard.h" /************************************************************************************************** * FUNCTIONS **************************************************************************************************/ /************************************************************************************************** * @fn main * * @brief Start of application. * * @param none * * @return none ************************************************************************************************** */ int main(void) { /* Initialize hardware */ HAL_BOARD_INIT(); // Initialize board I/O InitBoard( OB_COLD ); /* Initialze the HAL driver */ HalDriverInit(); /* Initialize NV system */ osal_snv_init(); /* Initialize LL */ /* Initialize the operating system */ osal_init_system(); /* Enable interrupts */ HAL_ENABLE_INTERRUPTS(); // Final board initialization InitBoard( OB_READY ); uint8 status; halUARTCfg_t uart_config; halUARTBufControl_t TxBufCtrl, RxBufCtrl; # define UART_BUF_LEN 10 # define CDI_PORT HAL_UART_PORT_0 TxBufCtrl.maxBufSize = UART_BUF_LEN; RxBufCtrl.maxBufSize = UART_BUF_LEN; RxBufCtrl.pBuffer = osal_mem_alloc(UART_BUF_LEN); uart_config.configured = TRUE; uart_config.baudRate = HAL_UART_BR_57600; uart_config.flowControl = HAL_UART_FLOW_OFF; uart_config.flowControlThreshold = 0x00; uart_config.idleTimeout = 6; uart_config.rx = RxBufCtrl; uart_config.tx = TxBufCtrl; uart_config.intEnable = FALSE; uart_config.callBackFunc = NULL;//(halUARTCBack_t) HalUARTCback; status = HalUARTOpen(CDI_PORT, &uart_config); /*if (status == HAL_UART_SUCCESS) { HalLcdWriteString( "OPEN P0 OK", HAL_LCD_LINE_1 ); } else { HalLcdWriteString( "OPEN P0 ERR", HAL_LCD_LINE_1 ); }*/ # if defined (NO_OSAL_LAYER) char tempuartwritetext[20]= "0123456789ABCDEFGHIJ"; halDMADesc_t *tempdmaCh1Tx= &dmaCh1Tx; HAL_DMA_SET_DEST( tempdmaCh1Tx, 0x70C1 ); // Using the length field to determine how many bytes to transfer. HAL_DMA_SET_VLEN( tempdmaCh1Tx, HAL_DMA_VLEN_USE_LEN ); // One byte is transferred each time. HAL_DMA_SET_WORD_SIZE( tempdmaCh1Tx, HAL_DMA_WORDSIZE_BYTE ); // The source address is incremented by 1 byte after each transfer. HAL_DMA_SET_SRC_INC( tempdmaCh1Tx, HAL_DMA_SRCINC_1 ); // The destination address is constant - the Tx Data Buffer. HAL_DMA_SET_DST_INC( tempdmaCh1Tx, HAL_DMA_DSTINC_0 ); // The DMA Tx done is serviced by ISR in order to maintain full thruput. //HAL_DMA_SET_IRQ( tempdmaCh1Tx, HAL_DMA_IRQMASK_ENABLE ); // Xfer all 8 bits of a byte xfer. HAL_DMA_SET_M8( tempdmaCh1Tx, HAL_DMA_M8_USE_8_BITS ); // DMA has second highest priority for memory access. HAL_DMA_SET_PRIORITY( tempdmaCh1Tx, HAL_DMA_PRI_GUARANTEED); HAL_DMA_SET_LEN(tempdmaCh1Tx,sizeof(tempuartwritetext)); HAL_DMA_SET_SOURCE(tempdmaCh1Tx,tempuartwritetext); HAL_DMA_SET_TRIG_MODE( tempdmaCh1Tx, HAL_DMA_TMODE_BLOCK);//HAL_DMA_TMODE_BLOCK_REPEATED);//HAL_DMA_TMODE_SINGLE_REPEATED );//HAL_DMA_TMODE_BLOCK HAL_DMA_SET_TRIG_SRC( tempdmaCh1Tx, HAL_DMA_TRIG_NONE);//HAL_DMA_TRIG_UTX0); HAL_DMA_CLEAR_IRQ(UART0TX_DMA); //if (DMAARM & (0x01 << UART0TX_DMA))//HAL_DMA_CH_ARMED (1) == 1) //while(1) do { while ((DMAARM & (0x01 << UART0TX_DMA)) == 0)//HAL_DMA_CH_ARMED (1) == 1) { //HAL_DMA_ARM_CH(UART0TX_DMA); DMAARM = DMAARM | (0x01 << UART0TX_DMA); asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop"); } HAL_DMA_MAN_TRIGGER(UART0TX_DMA); //HAL_DMA_SET_TRIG_SRC( tempdmaCh1Tx,HAL_DMA_TRIG_UTX0); asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop"); }while (0); while(1); #else #if defined ( POWER_SAVING ) osal_pwrmgr_device( PWRMGR_BATTERY ); #endif /* Start OSAL */ osal_start_system(); // No Return from here # endif return 0; } /************************************************************************************************** CALL-BACKS **************************************************************************************************/ /************************************************************************************************* **************************************************************************************************/
/************************************************************************************************** Filename: SimpleBLEPeripheral_Main.c Revised: $Date: 2010-07-06 15:39:18 -0700 (Tue, 06 Jul 2010) $ Revision: $Revision: 22902 $ Description: This file contains the main and callback functions for the Simple BLE Peripheral sample application. Copyright 2010 - 2011 Texas Instruments Incorporated. All rights reserved. IMPORTANT: Your use of this Software is limited to those specific rights granted under the terms of a software license agreement between the user who downloaded the software, his/her employer (which must be your employer) and Texas Instruments Incorporated (the "License"). You may not use this Software unless you agree to abide by the terms of the License. The License limits your use, and you acknowledge, that the Software may not be modified, copied or distributed unless embedded on a Texas Instruments microcontroller or used solely and exclusively in conjunction with a Texas Instruments radio frequency transceiver, which is integrated into your product. Other than for the foregoing purpose, you may not use, reproduce, copy, prepare derivative works of, modify, distribute, perform, display or sell this Software and/or its documentation for any purpose. YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE PROVIDED �AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS. Should you have any questions regarding your right to use this Software, contact Texas Instruments Incorporated at www.TI.com. **************************************************************************************************/ /************************************************************************************************** * Includes **************************************************************************************************/ /* Hal Drivers */ #include "hal_types.h" #include "hal_key.h" #include "hal_timer.h" #include "hal_drivers.h" #include "hal_led.h" #include "hal_lcd.h" #include "hal_uart.h" # define UART0TX_DMA 1 #define NO_OSAL_LAYER # if defined (NO_OSAL_LAYER) # include "hal_dma.h" extern halDMADesc_t dmaCh1Tx; extern halDMADesc_t dmaCh1TxDummy; # endif /* OSAL */ #include "OSAL.h" #include "OSAL_Tasks.h" #include "OSAL_PwrMgr.h" #include "osal_snv.h" #include "OnBoard.h" /************************************************************************************************** * FUNCTIONS **************************************************************************************************/ /************************************************************************************************** * @fn main * * @brief Start of application. * * @param none * * @return none ************************************************************************************************** */ int main(void) { /* Initialize hardware */ HAL_BOARD_INIT(); // Initialize board I/O InitBoard( OB_COLD ); /* Initialze the HAL driver */ HalDriverInit(); /* Initialize NV system */ osal_snv_init(); /* Initialize LL */ /* Initialize the operating system */ osal_init_system(); /* Enable interrupts */ HAL_ENABLE_INTERRUPTS(); // Final board initialization InitBoard( OB_READY ); uint8 status; halUARTCfg_t uart_config; halUARTBufControl_t TxBufCtrl, RxBufCtrl; # define UART_BUF_LEN 10 # define CDI_PORT HAL_UART_PORT_0 TxBufCtrl.maxBufSize = UART_BUF_LEN; RxBufCtrl.maxBufSize = UART_BUF_LEN; RxBufCtrl.pBuffer = osal_mem_alloc(UART_BUF_LEN); uart_config.configured = TRUE; uart_config.baudRate = HAL_UART_BR_57600; uart_config.flowControl = HAL_UART_FLOW_OFF; uart_config.flowControlThreshold = 0x00; uart_config.idleTimeout = 6; uart_config.rx = RxBufCtrl; uart_config.tx = TxBufCtrl; uart_config.intEnable = FALSE; uart_config.callBackFunc = NULL;//(halUARTCBack_t) HalUARTCback; status = HalUARTOpen(CDI_PORT, &uart_config); /*if (status == HAL_UART_SUCCESS) { HalLcdWriteString( "OPEN P0 OK", HAL_LCD_LINE_1 ); } else { HalLcdWriteString( "OPEN P0 ERR", HAL_LCD_LINE_1 ); }*/ # if defined (NO_OSAL_LAYER) char tempuartwritetext[20]= "0123456789ABCDEFGHIJ"; halDMADesc_t *tempdmaCh1Tx= &dmaCh1Tx; HAL_DMA_SET_DEST( tempdmaCh1Tx, 0x70C1 ); // Using the length field to determine how many bytes to transfer. HAL_DMA_SET_VLEN( tempdmaCh1Tx, HAL_DMA_VLEN_USE_LEN ); // One byte is transferred each time. HAL_DMA_SET_WORD_SIZE( tempdmaCh1Tx, HAL_DMA_WORDSIZE_BYTE ); // The source address is incremented by 1 byte after each transfer. HAL_DMA_SET_SRC_INC( tempdmaCh1Tx, HAL_DMA_SRCINC_1 ); // The destination address is constant - the Tx Data Buffer. HAL_DMA_SET_DST_INC( tempdmaCh1Tx, HAL_DMA_DSTINC_0 ); // The DMA Tx done is serviced by ISR in order to maintain full thruput. //HAL_DMA_SET_IRQ( tempdmaCh1Tx, HAL_DMA_IRQMASK_ENABLE ); // Xfer all 8 bits of a byte xfer. HAL_DMA_SET_M8( tempdmaCh1Tx, HAL_DMA_M8_USE_8_BITS ); // DMA has second highest priority for memory access. HAL_DMA_SET_PRIORITY( tempdmaCh1Tx, HAL_DMA_PRI_GUARANTEED); HAL_DMA_SET_LEN(tempdmaCh1Tx,sizeof(tempuartwritetext)); HAL_DMA_SET_SOURCE(tempdmaCh1Tx,tempuartwritetext); HAL_DMA_SET_TRIG_MODE( tempdmaCh1Tx, HAL_DMA_TMODE_SINGLE_REPEATED);//HAL_DMA_TMODE_BLOCK_REPEATED);//HAL_DMA_TMODE_SINGLE_REPEATED );//HAL_DMA_TMODE_BLOCK HAL_DMA_SET_TRIG_SRC( tempdmaCh1Tx, HAL_DMA_TRIG_NONE);//HAL_DMA_TRIG_UTX0); HAL_DMA_CLEAR_IRQ(UART0TX_DMA); //if (DMAARM & (0x01 << UART0TX_DMA))//HAL_DMA_CH_ARMED (1) == 1) while(1) //do { while ((DMAARM & (0x01 << UART0TX_DMA)) == 0)//HAL_DMA_CH_ARMED (1) == 1) { //HAL_DMA_ARM_CH(UART0TX_DMA); DMAARM = DMAARM | (0x01 << UART0TX_DMA); asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop"); } HAL_DMA_MAN_TRIGGER(UART0TX_DMA); HAL_DMA_SET_TRIG_SRC( tempdmaCh1Tx,HAL_DMA_TRIG_UTX0); asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop"); }//while (0); while(1); #else #if defined ( POWER_SAVING ) osal_pwrmgr_device( PWRMGR_BATTERY ); #endif /* Start OSAL */ osal_start_system(); // No Return from here # endif return 0; } /************************************************************************************************** CALL-BACKS **************************************************************************************************/ /************************************************************************************************* **************************************************************************************************/
Hi
My code snippet is below. My goal is to transmit on UART using DMA. I have the following problems
Option 1:
When I use the HAL_DMA_TMODE_BLOCK mode with Manual trigger to begin the TX (HAL_DMA_TRIG_NONE) and then switch over to HAL_DMA_TRIG_UTX0 trigger, the problem I am facing is that the transfer continues on an on and there is no way of stopping it ( I know I am in an infinite loop. The code does not TX without it). More over the data that is sent is also semi junk. Part of it is valid and some other parts are invalid.
Data I planned to send -> "0123456789ABCDEFGHIJ";
Data out -> JBJ7J3JJJJFJBJ7J3JJJJFJCJ8J4J0JJGJDJ9J5J1JJHJDJ9J5J1JJHJEJAJ6J2JJIJEJBJ7J3JJJJFJBJ7J3JJJJFJCJ8J4J0JJGJDJ9J5J1JJHJDJ9J5J1JJHJEJAJ6J2JJIJEJBJ7J3JJJJFJBJ7J3JJJJFJCJ8J4J0JJGJDJ9J5J1JJHJDJ9J5J1JJHJEJAJ6J2JJIJEJBJ7
Option 2:
When I use the HAL_DMA_TMODE_BLOCK mode with Manual trigger to begin the TX (HAL_DMA_TRIG_NONE) , the problem I am facing is that the transfer continues on an on and there is no way of stopping it ( I know I am in an infinite loop. The code does not TX without it). More over the data that is sent is also semi junk. Part of it is valid and some other parts are invalid.
Data I planned to send -> "0123456789ABCDEFGHIJ";
Data out -> 06BHJJJJJ4AFJJJJJ28DJJJJJ06BHJJJJJ4AFJJJJJ28DJJJJJ06BHJJJJJ4AFJJJJJ28DJJJJJ06BHJJJJJ4AFJJJJJ28DJJJJJ06BHJJJJJ4AFJJJJJ28DJJJJJ06BHJJJJJ4AFJJJJJ28
Option 3:
When I use the HAL_DMA_TMODE_BLOCK mode with Manual trigger to begin the TX (HAL_DMA_TRIG_NONE) and then switch over to HAL_DMA_TRIG_UTX0 trigger, the problem I am facing is that the transfer continues on an on and there is no way of stopping it ( I know I am in an infinite loop. The code does not TX without it). More over the data that is sent is also semi junk. Part of it is valid and some other parts are invalid.
Data I planned to send -> "0123456789ABCDEFGHIJ";
Data out ->DEFGHIJ0123456789ABCDEFGHIJ0123456789ABCDEFGHIJ0123456789ABCDEFGHIJ0123456789ABCDEFGHIJ0123456789ABCDEFGHIJ0123456789ABCDEFGHIJ0123456789ABCDEFGHIJ0123456789ABC
The problem I face in option 3 is that the transfer never stops !!!!! Even if the controller stops at a debug breakpoint. The dilemma is that the TX does not begin without the infinite loop and does not end may be because I am in an infinite loop.
//common configuration code
# define UART0TX_DMA 1
extern halDMADesc_t dmaCh1Tx;
char tempuartwritetext[20]= "0123456789ABCDEFGHIJ";
halDMADesc_t *tempdmaCh1Tx= &dmaCh1Tx;
HAL_DMA_SET_DEST( tempdmaCh1Tx, 0x70C1 );
// Using the length field to determine how many bytes to transfer.
HAL_DMA_SET_VLEN( tempdmaCh1Tx, HAL_DMA_VLEN_USE_LEN );
// One byte is transferred each time.
HAL_DMA_SET_WORD_SIZE( tempdmaCh1Tx, HAL_DMA_WORDSIZE_BYTE );
// The source address is incremented by 1 byte after each transfer.
HAL_DMA_SET_SRC_INC( tempdmaCh1Tx, HAL_DMA_SRCINC_1 );
// The destination address is constant - the Tx Data Buffer.
HAL_DMA_SET_DST_INC( tempdmaCh1Tx, HAL_DMA_DSTINC_0 );
// The DMA Tx done is serviced by ISR in order to maintain full thruput.
//HAL_DMA_SET_IRQ( tempdmaCh1Tx, HAL_DMA_IRQMASK_ENABLE );
// Xfer all 8 bits of a byte xfer.
HAL_DMA_SET_M8( tempdmaCh1Tx, HAL_DMA_M8_USE_8_BITS );
// DMA has second highest priority for memory access.
HAL_DMA_SET_PRIORITY( tempdmaCh1Tx, HAL_DMA_PRI_GUARANTEED);
HAL_DMA_SET_LEN(tempdmaCh1Tx,sizeof(tempuartwritetext));
HAL_DMA_SET_SOURCE(tempdmaCh1Tx,tempuartwritetext);
HAL_DMA_SET_TRIG_MODE( tempdmaCh1Tx, HAL_DMA_TMODE_BLOCK);//HAL_DMA_TMODE_BLOCK_REPEATED);//HAL_DMA_TMODE_SINGLE_REPEATED );//HAL_DMA_TMODE_BLOCK
HAL_DMA_SET_TRIG_SRC( tempdmaCh1Tx, HAL_DMA_TRIG_NONE);//HAL_DMA_TRIG_UTX0);
HAL_DMA_CLEAR_IRQ(UART0TX_DMA);
//code for option 1
while(1)
//do
{
while ((DMAARM & (0x01 << UART0TX_DMA)) == 0)//HAL_DMA_CH_ARMED (1) == 1)
{
//HAL_DMA_ARM_CH(UART0TX_DMA);
DMAARM = DMAARM | (0x01 << UART0TX_DMA);
asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");
}
HAL_DMA_MAN_TRIGGER(UART0TX_DMA);
HAL_DMA_SET_TRIG_SRC( tempdmaCh1Tx,HAL_DMA_TRIG_UTX0);
asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");
}