Forum: Mikrocontroller und Digitale Elektronik MSP430FR5994 SPI


von Frank B. (rank_b)


Lesenswert?

Hallo,
ich versuche gerade mit dem MSP430FR5994 den SPI Bus zu verwenden. 
Hierzu verwende ich UCB1  also die Pins 5.0, 5.1, 5.2
Zum Testen habe ich ein Beispiel von driverlib genommen und die 
driverlib natürlich eingebunde.

An die Pins habe ich ein oszi angeschlossen. Bis auf die CS Leitung 
passiert aber nichts. Alle Pegel sind auf High. Müsste nicht wenigstens 
bei SIMO irgend was zu sehen sein?

Habe ich noch irgend ein Denkfehler?
1
WDTCTL = WDTPW | WDTHOLD;
2
//Set DCO frequency to max DCO setting
3
CS_setDCOFreq(CS_DCORSEL_0,CS_DCOFSEL_3);
4
//Select DCO as the clock source for SMCLK with no frequency divider
5
CS_initClockSignal(CS_SMCLK,CS_DCOCLK_SELECT,CS_CLOCK_DIVIDER_1); 
6
 /*
7
   * Select CS
8
   * Set Pin 0 as output
9
   */
10
  GPIO_setAsOutputPin(
11
        GPIO_PORT_P5,
12
        GPIO_PIN4
13
  );
14
  
15
  /*
16
   * Select Port 5
17
   * Set Pin 0 to output Low.
18
  */
19
    GPIO_setOutputLowOnPin(
20
        GPIO_PORT_P5,
21
        GPIO_PIN4
22
    );
23
    
24
    //Configure Pins for UCB0CLK
25
    GPIO_setAsPeripheralModuleFunctionInputPin(
26
        GPIO_PORT_P5,
27
        GPIO_PIN2,
28
        GPIO_SECONDARY_MODULE_FUNCTION
29
    );
30
31
    //Configure Pins for UCB0TXD/UCB0SIMO, UCB0RXD/UCB0SOMI
32
    GPIO_setAsPeripheralModuleFunctionInputPin(
33
        GPIO_PORT_P5,
34
        GPIO_PIN0 + GPIO_PIN1,
35
        GPIO_SECONDARY_MODULE_FUNCTION
36
    );
37
38
   /*
39
    * Disable the GPIO power-on default high-impedance mode to activate
40
    * previously configured port settings
41
    */
42
    PMM_unlockLPM5();
43
    
44
    //Initialize Master
45
    EUSCI_B_SPI_initMasterParam param = {0};
46
    param.selectClockSource = EUSCI_B_SPI_CLOCKSOURCE_SMCLK;
47
    param.clockSourceFrequency = CS_getSMCLK();
48
    param.desiredSpiClock = 500000;
49
    param.msbFirst = EUSCI_B_SPI_MSB_FIRST;
50
    param.clockPhase =     EUSCI_B_SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT;
51
52
    param.clockPolarity = EUSCI_B_SPI_CLOCKPOLARITY_INACTIVITY_HIGH;
53
    param.spiMode = EUSCI_B_SPI_3PIN;
54
    EUSCI_B_SPI_initMaster(EUSCI_B1_BASE, &param);
55
56
    //Enable SPI module
57
    EUSCI_B_SPI_enable(EUSCI_B1_BASE);
58
59
    //Clear RXIFG interrupt flag
60
    EUSCI_B_SPI_clearInterrupt(EUSCI_B1_BASE, EUSCI_B_SPI_RECEIVE_INTERRUPT);
61
    
62
    // Enable USCI_B0 RX interrupt
63
    EUSCI_B_SPI_enableInterrupt(EUSCI_B1_BASE,
64
        EUSCI_B_SPI_RECEIVE_INTERRUPT);
65
    
66
    //Wait for slave to initialize
67
    __delay_cycles(100);
68
    
69
   
70
    while (1) {
71
72
      uiTXData = 0x11;                             // Holds TX data
73
      
74
      //USCI_B0 TX buffer ready?
75
      while (!EUSCI_B_SPI_getInterruptStatus(EUSCI_B1_BASE,
76
        EUSCI_B_SPI_TRANSMIT_INTERRUPT)) ;
77
78
      //Transmit Data to slave
79
      EUSCI_B_SPI_transmitData(EUSCI_B1_BASE, uiTXData);
80
         
81
    }

von Frank B. (rank_b)


Lesenswert?

Vielleicht noch als Anmerkung, wenn ich die UART ohne driverlib 
initialisiere, dann funktioniert sie.
1
// Configure GPIO
2
P5SEL1 &= ~(BIT0 | BIT1 | BIT2);        // USCI_B1 SCLK, MOSI, and MISO pin
3
P5SEL0 |= (BIT0 | BIT1 | BIT2);
4
PJSEL0 |= BIT4 | BIT5;                  // For XT1
5
  
6
 // Configure USCI_B1 for SPI operation
7
UCB1CTLW0 = UCSWRST;                   // **Put state machine in reset**
8
UCB1CTLW0 |= UCMST | UCSYNC | UCCKPL | UCMSB;    // 3-pin, 8-bit SPI master
9
                                                 // Clock polarity high, MSB
10
    
11
UCB1CTLW0 |= UCSSEL__ACLK;              // ACLK
12
UCB1BRW = 0x02;                         // /2
13
//UCB1MCTLW = 0;                          // No modulation
14
UCB1CTLW0 &= ~UCSWRST;                  // **Initialize USCI state machine**
15
UCB1IE |= UCRXIE;                       // Enable USCI_B1 RX interrupt
16
//TXData = 0x1;                           // Holds TX data
was mache ich bei der Initialisierung mir driverlib falsch?

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.