MSP430f1611 DMA

OP #4612431
Lesenswert?

Hallo zusammen,

ich habe ein kleines Problem mit meinem Programm. Irgendwie bekomme ich 
nichts vernüftiges gesendet... Vielleicht könnte mir hier ja jemand 
helfen?
1
#include <msp430.h> 
2
#include "bocas.h"
3
#include "main.h"
4

5
int dmaRS232(const char *text, unsigned int length);
6
int dmaInit();
7

8
static char string1[] = { "a" };
9

10
void rs232Init(void)
11
{
12
  BITSET(P3SEL, 0xC0);
13
  BITSET(P3DIR, 0x40);
14

15
  BITSET(U1CTL, SWRST);
16
  BITSET(ME2, UTXE1+URXE1);
17
  BITSET(U1TCTL, SSEL0);
18
  BITCLR(U1CTL, SYNC);
19
  BITCLR(U1CTL, PENA|SPB);
20
  BITCLR(U1CTL, CHAR);
21
  U1BR0 = LOW_16(69);
22
  U1BR1 = HIGH_16(69);
23
  U1MCTL = 0xAA;
24
  BITCLR(U1CTL, SWRST);
25
}
26

27
void initInterruptControlledIO(void)
28
{
29
  rs232Init();
30

31
  // Watchdog deaktivieren
32
  WDTCTL = WDT_MDLY_32;
33

34
  BITCLR(IFG2, URXIFG1);
35
  BITSET(IE2, URXIE1);
36

37
  INT_ENABLE;
38
}
39

40
#pragma vector=DMA_VECTOR
41
__interrupt void DMA_ISR (void)
42
{
43
  BITSET(DMA1CTL, DMAEN);
44
}
45

46
int dmaInit()
47
{
48
  BITSET(DMACTL0, DMA1TSEL_10);            // Enable UART1
49

50
  BITSET(DMA1CTL, (DMADSTBYTE|DMASRCBYTE));      // Set Byte-Mode
51

52
  BITSET(DMA1CTL, DMADT_0);
53
  BITSET(DMA1CTL, DMASRCINCR_3);
54
  BITCLR(DMA1CTL, DMAIE);
55
  BITCLR(DMA1CTL, DMAEN);
56

57
  return 0;
58
}
59

60
void main(void)
61
{
62
  initInterruptControlledIO();
63
  dmaInit();
64

65
  /* run echo loop */
66
  while(1) /* run forever */
67
  {
68
    dmaRS232(string1, sizeof(string1));
69
  }
70
}
71

72
/* Name: dmaRS232                           */
73
/* Function:                              */
74
/* Parameters:                              */
75
/* Return:                                */
76
int dmaRS232 ( const char *text, unsigned int len )
77
{
78
  DMA1SZ = len - 1;
79
  DMA1SA = (int)text + 1;
80
  DMA1DA = &U1TXBUF;
81

82
  U1TXBUF = text[0];
83

84
  BITSET(DMA1CTL, DMAEN);
85

86
  while((DMA1CTL & DMAIFG) != 1);
87

88
  return 0;
89
} /* end dmaRS232                           */

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren