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,
i work with the msp430f5438A , and with the IDE CCs 5.3.
My question is about the operation of the DMA. the first program is a program that works well and sends data when the trigger is by the UART ( communication) .
Now I want to change ( and to writhe second program) in such a way that the trigger will be by software.
(both of the programs are send block transfer)
in the next program I made the following change(can see bellow, in the second program, the change mark in yellow):
1. I change the trigger: DMACTL0 = DMA0TSEL_17è DMA0TSEL_0
2. and add the DMA trigger as: DMA0CTL |= DMAREQ;
******** The program that works well before the changes is:*****************
/* ------------------------------------------------------------------------ */
/* Include Files */
/* ------------------------------------------------------------------------ */
#include <msp430.h>
#include <string.h>// for strlen();
/* ------------------------------------------------------------------------ */
/* (global) Constants Definitions, Macro Definitions */
/* ------------------------------------------------------------------------ */
typedef unsigned int Uint16;
typedef unsigned char Uint8;
const char String[] = "Hello World\r\n";
/* ------------------------------------------------------------------------ */
/* Imported (External) Function */
/* ------------------------------------------------------------------------ */
extern void ClockCnfg (void);
extern void TimerA1Cnfg (void);
extern void PortCnfg ( void );
extern void CommCnfg(void);
void DmaCnfg (void);
/* ------------------------------------------------------------------------ */
/* Functions Body */
/* ------------------------------------------------------------------------ */
int main(void)
{
__bic_SR_register(GIE); // disable interrupt.
PortCnfg();
ClockCnfg();// 16mhz
TimerA1Cnfg();//timer interrupt of 10Hz.and blink the led
CommCnfg(); // Initialize the communication.57600 BR.
DmaCnfg();
__bis_SR_register(GIE); // enable interrupts
while(1)
{
while ((DMA0CTL & DMAEN) != 0)// wait here, the DMAEN clear after the
// completion of the block transfer. and must be set again before a
// another block transfer can be trigger .
{
__no_operation();// Required only for debugger
}
DMA0CTL |= DMAEN;
}
}
void DmaCnfg (void) {
//DMA configuration.
DMA0CTL &= ~DMAEN;
/* DMAxTSEL bits should be modified only
* when the DMACTLx DMAEN bit is 0
*/
DMACTL0 = DMA0TSEL_17;// USCI_A0 TXIFG trigger(the trigger : UCA0TXIFG)
// Source block address, is message.
__data16_write_addr((unsigned short) &DMA0SA,(unsigned long) String);
// Destination single address
__data16_write_addr((unsigned short) &DMA0DA,(unsigned long) &UCA0TXBUF);
DMA0SZ = strlen(String); // Block size
// DMADT_0 = 000b = Single transfer
DMA0CTL |= (
DMADT_1/*block transfer*/
//DMADT_2 /* Burst-Block transfer */
+DMASRCINCR_3 /* Source address is incremented */
+DMASBDB /* DMA source byte.
* This bit selects the source as a byte or word.
**/
+DMALEVEL
/*DMA level. This bit selects between edge-sensitive
* and level-sensitive triggers.
* 1b = Level sensitive (high level) */
);
DMA0CTL |= DMAEN;// DMA enable.
}
********** till here, end of the first program *****************************************************
The next program is with SW trigger ( and from some reason it not work, i don't find the reason yet).
I made the follwing change ( as I mention above, the chages is mark in yellow in the next program) .
1. DMACTL0 = DMA0TSEL_17è DMA0TSEL_0
2. and add the DMA trigger as: DMA0CTL |= DMAREQ;
I get the following program( that from some reason no transmit any data, and i still didn't find the reason) :
******** the second progrma start from here ************************
/* ------------------------------------------------------------------------ */
/* Include Files */
/* ------------------------------------------------------------------------ */
#include <msp430.h>
#include <string.h>// for strlen();
/* ------------------------------------------------------------------------ */
/* (global) Constants Definitions, Macro Definitions */
/* ------------------------------------------------------------------------ */
const char String[] = "Hello World\r\n";
/* ------------------------------------------------------------------------ */
/* Imported (External) Function */
/* ------------------------------------------------------------------------ */
extern void ClockCnfg (void);
extern void TimerA1Cnfg (void);
extern void PortCnfg ( void );
extern void CommCnfg(void);
void DmaCnfg (void);
/* ------------------------------------------------------------------------ */
/* Functions Body */
/* ------------------------------------------------------------------------ */
int main(void)
{
__bic_SR_register(GIE); // disable interrupt.
PortCnfg();
ClockCnfg();// 16mhz
TimerA1Cnfg();//timer interrupt of 10Hz.and blink the led
CommCnfg(); // Initialize the communication.57600 BR.
DmaCnfg();
__bis_SR_register(GIE); // enable interrupts
while(1)
{
while ((DMA0CTL & DMAEN) != 0)// wait here, the DMAEN clear after the
// completion of the block transfer. and must be set again before a
// another block transfer can be trigger .
{
__no_operation();// Required only for debugger
}
DMA0CTL |= DMAEN; // enable DMA again before another block is trigger.
DMA0CTL |= DMAREQ;// trigger another sending.
}
}
void DmaCnfg (void) {
//DMA configuration.
DMA0CTL &= ~DMAEN;
/* DMAxTSEL bits should be modified only
* when the DMACTLx DMAEN bit is 0
*/
DMACTL0 = DMA0TSEL_0;
/* DMA channel 0
* transfer select 0: DMA_REQ (sw)*/
// Source block address, is message.
__data16_write_addr((unsigned short) &DMA0SA,(unsigned long) String);
// Destination single address
__data16_write_addr((unsigned short) &DMA0DA,(unsigned long) &UCA0TXBUF);
DMA0SZ = strlen(String); // Block size
// DMADT_0 = 000b = Single transfer
DMA0CTL |= (
DMADT_1/*block transfer*/
//DMADT_2 /* Burst-Block transfer */
+DMASRCINCR_3 /* Source address is incremented */
+DMASBDB /* DMA source byte.
* This bit selects the source as a byte or word.
**/
+DMALEVEL
/*DMA level. This bit selects between edge-sensitive
* and level-sensitive triggers.
* 1b = Level sensitive (high level) */
);
DMA0CTL |= DMAEN;// DMA enable.
DMA0CTL |= DMAREQ;// trigger.
}
******** till here, end of the second program ************************
is any one have hint why the second program not work and how to fix it?
what is wrong with the SW trigger (DMAREQ).
thanks.
**Attention** This is a public forum