Forum: Mikrocontroller und Digitale Elektronik ARM LM3S811 SSI Problem


von Anfänger (Gast)


Lesenswert?

Hallo,

ich habe mir ein EK LM3S811 gekauft und möchte nun über die
SSI-Schnittstelle etwas ausgeben. Ich möchte nun anfangs die
Probe-Applikation aus dem User Guide verwenden und mit dem Oszi
prüfen, ob es wirklich funktioniert.
Doch bis jetzt habe ich es nicht erreicht, dass das Oszi etwas ausgibt.

Hier meine Programm, dass ich dazu verwende:
1
int main()
2
{
3
#include "hw_types.h"
4
#include "hw_memmap.h"
5
#include "hw_ints.h"
6
#include "sysctl.h"
7
#include "sysctl.c"
8
#include "ssi.c"
9
#include "ssi.h"
10
#include "lm3s811.h"
11
#include "debug.h"
12
#include "gpio.h"
13
#include "interrupt.h"
14
15
16
  SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_6MHZ);
17
  
18
  SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI1);
19
  
20
  SSIConfigSetExpClk(SSI_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_0,
21
                   SSI_MODE_MASTER, 2000000, 8);
22
  
23
  
24
  char *pcChars = "SSI Master send data.";
25
  long lIdx;
26
     
27
     //
28
    // Enable the SSI module.
29
    //
30
  SSIEnable(SSI_BASE);
31
    //
32
    // Send some data.
33
    //
34
  lIdx = 0;
35
  while(lIdx)
36
  {
37
    
38
    (SSIDataPut(SSI_BASE, pcChars[lIdx]));
39
 /* {
40
    lIdx++;
41
  }*/
42
}
43
  return 0;
44
}

Ich glaube nicht, dass ich alle Header-Dateien benötige, aber lieber zu
viel wie zu wenig. Welche Initialisierungen fehlen mir noch??

von Andreas W. (andreasw) Benutzerseite


Lesenswert?

Das geht nicht gut:
1
  lIdx = 0;
2
  while(lIdx)
3
...

Und ein paar Sachen fehlen noch:
1
//GPIO-Port anschalten
2
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOx);
3
4
//rx -> Input mit Pull-up
5
GPIOPinTypeGPIOInput(GPIO_PORTx_BASE, GPIO_PIN_x);
6
GPIOPadConfigSet(GPIO_PORTx_BASE, GPIO_PIN_x, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
7
8
//tx, clk -> Output
9
GPIOPinTypeGPIOOutput(GPIO_PORTx_BASE, GPIO_PIN_y | GPIO_PIN_z);
10
GPIOPadConfigSet(GPIO_PORTx_BASE, GPIO_PIN_y | GPIO_PIN_z, GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD);
11
12
//Pins an SSI übergeben
13
GPIOPinTypeSSI(GPIO_PORTx_BASE, GPIO_PIN_x | GPIO_PIN_y | GPIO_PIN_z);

von Anfänger (Gast)


Lesenswert?

Danke für die rasche Antwort,
ich weiß, aber da diese Angabe direkt vom
User Guide entnommen ist, wundere ich mich wirklich.

Habe die Pin Konfigurationen übernommen, kann aber leider immer noch
nichts aufm Oszi sehen.

Auch die ursprüngliche Schleife:
1
while(pcChars[lIdx])
2
{
3
if(SSIDataPut(SSI_BASE, pcChars[lIdx]))
4
{
5
lIdx++;
6
}
7
}


verwundert mich, denn SSIDataPut ist eine Void-Funktion
und hat somit keinen Returnwert, aber wie soll dann die Schleife 
überhaupt
ausgeführt werden ??

von Andreas W. (andreasw) Benutzerseite


Lesenswert?

Versuche mal einen Pin zu togglen, um zu sehen ob das Programm auch 
ausgeführt wird.

Deine Schleife aus dem ersten Post wird überhaupt nicht abgearbeitet, 
weil lIdx auf 0 gesetzt ist und die Schleife aus dem DB sendet immer 
das selbe Zeichen -> pcChars[0] -> 'S'

Der Code aus dem DB ist vielleicht für eine ältere Version der DriverLib 
gedacht - SSIDataPut() ist wahrscheinlich jetzt SSIDataPutNonBlocking()

von Anfänger (Gast)


Lesenswert?

So, jetzt habe ich ein Beispielprogramm gefunden, dass zwar eigentlich
für das Development Kit LM3S811 ausgelegt ist, aber in diesem Beispiel
wird ebenfalls die SSI-Schnittstelle verwendet, um mit einem Atmel 
EEPROM#
zu kommuniezieren. Das Programm läuft einwandfrei, nur komme ich nicht 
dahinter
wie ich meinem jetztigen Code:
1
int main()
2
{
3
  // SSI anschalten
4
  SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);
5
  //GPIO-Port anschalten
6
  SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
7
  
8
 IntMasterEnable();
9
10
  //rx -> Input mit Pull-up
11
  GPIOPinTypeGPIOInput(GPIO_PORTA_BASE, SSI_RX);
12
  GPIOPadConfigSet(GPIO_PORTA_BASE, SSI_RX, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
13
14
  //tx, clk -> Output
15
  GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, SSI_TX);
16
  GPIOPadConfigSet(GPIO_PORTA_BASE, SSI_TX, GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD);
17
18
  //Pins an SSI übergeben
19
  GPIOPinTypeSSI(GPIO_PORTA_BASE, SSI_RX | SSI_TX); 
20
  
21
  // Clock der Peripherie angeben 
22
  SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_6MHZ);
23
  
24
  // SSI anschalten
25
  SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI1);
26
  
27
  // SSI Konfigurationen einstellen
28
  SSIConfigSetExpClk(SSI_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_3,
29
                   SSI_MODE_MASTER, 2000000, 8);
30
  
31
  // SSI aktivieren
32
  SSIEnable(SSI_BASE);
33
  
34
  
35
  char *pcChars = "SSI Master send data.";
36
  long lIdx;
37
     
38
39
  lIdx = 1;
40
  while(lIdx)
41
  {
42
    
43
    (SSIDataPut(SSI_BASE, pcChars[lIdx]));
44
  
45
    lIdx++;
46
  
47
  }
48
  return 0;
49
}
noch ändern muss oder was ich vergessen habe zu initialisieren.

von Andreas W. (andreasw) Benutzerseite


Lesenswert?

Wie sind denn SSI_RX und SSI_TX deklariert? Du musst auch noch den 
Clk-Pin konfigurieren und dem SSI übergeben.

Wenn ich jetzt nichts übersehen habe, dann müsste folgender 
Codeschnipsel funktionieren und andauernd etwas senden:
1
int main()
2
{
3
  // Sys-Clock setzen
4
  SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_6MHZ);
5
6
  // GPIO-Port anschalten
7
  SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
8
9
  // SSI anschalten
10
  SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);
11
12
  // rx -> Input mit Pull-up
13
  GPIOPinTypeGPIOInput(GPIO_PORTA_BASE, GPIO_PIN_4);
14
  GPIOPadConfigSet(GPIO_PORTA_BASE, GPIO_PIN_4, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
15
16
  // tx und clk -> Output
17
  GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_2 | GPIO_PIN_5);
18
  GPIOPadConfigSet(GPIO_PORTA_BASE, GPIO_PIN_2 | GPIO_PIN_5, GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD);
19
20
  // Pins an SSI übergeben
21
  GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_2 | GPIO_PIN_4 | GPIO_PIN_5); 
22
23
  // SSI Konfigurationen einstellen
24
  SSIConfigSetExpClk(SSI0_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_3, SSI_MODE_MASTER, 2000000, 8);
25
  
26
  // SSI aktivieren
27
  SSIEnable(SSI0_BASE);
28
29
  volatile unsigned long i;
30
31
  while(1)
32
  {
33
    SSIDataPut(SSI0_BASE, 'S');
34
35
    for(i=50000; i!=0; i--);
36
  }
37
38
  return 0;
39
}

von Anfänger (Gast)


Lesenswert?

Ich habe SSI_RX und TX so deklariert:
1
#define SSI_CS                  GPIO_PIN_3
2
#define SSI_CLK                 GPIO_PIN_2
3
#define SSI_TX                  GPIO_PIN_5
4
#define SSI_RX                  GPIO_PIN_4


Aber leider kann ich immer noch nichts sehen.
Muss ich vielleicht noch einen Interrupt setzten?
Ich kann auch nicht mit dem Debugger das Programm einzelnen durchlaufen,
es wirkt fast so, als ob ich irgendwo in einer Endlosschleife drin wäre.

Hier noch einmal mein gesamtes Programm, wie es wirklich aussieht:
1
#include "ersterVersuch.h"
2
3
4
int main()
5
{
6
 
7
  // Clock der Peripherie angeben 
8
  SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_6MHZ);
9
  
10
   //GPIO-Port anschalten
11
  SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
12
  
13
  // SSI anschalten
14
  SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);
15
 
16
  //rx -> Input mit Pull-up
17
  GPIOPinTypeGPIOInput(GPIO_PORTA_BASE, SSI_RX);
18
  GPIOPadConfigSet(GPIO_PORTA_BASE, SSI_RX, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
19
  
20
   //tx, clk -> Output
21
  GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, SSI_TX | SSI_CLK);
22
  GPIOPadConfigSet(GPIO_PORTA_BASE, SSI_TX | SSI_CLK, GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD);
23
  
24
  //Pins an SSI übergeben
25
  GPIOPinTypeSSI(GPIO_PORTA_BASE, SSI_CLK | SSI_TX | SSI_RX); 
26
  
27
  // SSI Konfigurationen einstellen
28
  SSIConfigSetExpClk(SSI0_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_3, SSI_MODE_MASTER, 2000000, 8);
29
  
30
  //SSI aktivieren  
31
  SSIEnable(SSI0_BASE);
32
33
  while(1)
34
  {
35
    SSIDataPut(SSI0_BASE, 'S');
36
37
    for(i=50000; i!=0; i--);
38
  }
39
40
  return 0;
41
}

Und die Header-Dateien
1
#include "...\hw_types.h"
2
#include "...\hw_memmap.h"
3
#include "...\hw_ints.h"
4
#include "...\sysctl.h"
5
#include "...\sysctl.c"
6
#include "...\ssi.c"
7
#include "...\ssi.h"
8
#include "...debug.h"
9
#include "...\interrupt.h"
10
#include "...\interrupt.c"
11
#include "...\gpio.h"
12
#include ":...\gpio.c"
13
#include "...\cpu.h"
14
#include "...\asmdefs.h"
15
#include "...\diag.h"
16
17
18
#define SSI_CS                  GPIO_PIN_3
19
#define SSI_CLK                 GPIO_PIN_2
20
#define SSI_TX                  GPIO_PIN_5
21
#define SSI_RX                  GPIO_PIN_4
22
23
volatile unsigned long i;

Ich weiß im Moment leider nicht, wie ich weitermachen kann.

von Anfänger (Gast)


Lesenswert?

Jetzt weiß ich, wo mein Problem liegt:
Ich lande immer in einer Endlosschleife von Startup.c aufgrund
eines falschen Interrupts, aber was ich dagegen machen soll ist mir
immernoch unklar.

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.