Forum: Mikrocontroller und Digitale Elektronik xmega SPI, PDI problem


von Johannes Gerken (Gast)


Lesenswert?

Hallo,

ich habe ein Problem mit einem SPI unterm xmega256a3b.
Ich sende ein byte über den SPID an einen 74HC595D.
Dieses klappt, solange ich meinen PDI Programmer angeschlossen habe 
(jtagice3) wenn ich den Programmer abziehe und das Programm startet geht 
alles bis auf die SPI kommunikation. Wenn ich den programmer wieder 
anschließe, er resettet und ich im AVRstudio auf "Continue" drücke geht 
der SPI wieder. Ich habe am PDI schon mit und ohne externen 10k pullup 
versucht.
Hier mein SPI code (ASF3)
1
//SPID ist das spi modul, das ganze laeuft bei 32Mhz
2
#define P_SPI3   IOPORT_CREATE_PIN(PORTA,2)//chip select
3
struct spi_device SPI_controlcircuit;
4
ioport_configure_pin(P_SPI1,IOPORT_INIT_HIGH | IOPORT_DIR_OUTPUT);
5
ioport_configure_port_pin(&PORTD, PIN6_bm, IOPORT_INIT_LOW | IOPORT_DIR_OUTPUT);
6
ioport_configure_port_pin(&PORTD, PIN4_bm, IOPORT_PULL_UP | IOPORT_DIR_INPUT);
7
ioport_configure_port_pin(&PORTD, PIN5_bm, IOPORT_INIT_HIGH | IOPORT_DIR_OUTPUT);
8
ioport_configure_port_pin(&PORTD, PIN7_bm, IOPORT_INIT_HIGH | IOPORT_DIR_OUTPUT);
9
10
sysclk_enable_module(SYSCLK_PORT_D, PR_SPI_bm);
11
SPI_controlcircuit.id= P_SPI3;
12
uint8_t c1[1]={0xA5};//byte zum senden
13
spi_master_init(&SPID);
14
spi_master_setup_device(&SPID, &SPI_controlcircuit, SPI_MODE_0, 1000000 , 0);//1000000 ist die geschwindigkeit
15
16
spi_enable(&SPID);
17
spi_select_device(&SPID, &SPI_controlcircuit);
18
spi_write_packet(&SPID, c1, 1);//senden     
19
spi_deselect_device(&SPID, &SPI_controlcircuit);

Hat jemand eine Lösung? Oder einen Tipp, wie ich das debuggen könnte?

von Johannes Gerken (Gast)


Lesenswert?

Nachtrag:
Irgendwie geht der SPI nur, wenn ich das Programm über den Continue 
Knopf im AVR-Studio Starte. Alles andere geht auch ohne 
AVR-Studio/Programmer.

von Basti (Gast)


Lesenswert?

Bei mir gehts so:
1
  #ifdef CONF_BOARD_AT45DBX
2
  ioport_configure_pin(AT45DBX_MASTER_SS, IOPORT_DIR_OUTPUT | IOPORT_INIT_HIGH);
3
  ioport_configure_pin(AT45DBX_MASTER_SCK, IOPORT_DIR_OUTPUT  | IOPORT_INIT_HIGH);
4
  ioport_configure_pin(AT45DBX_MASTER_MOSI, IOPORT_DIR_OUTPUT  | IOPORT_INIT_HIGH);
5
  ioport_configure_pin(AT45DBX_CS, IOPORT_DIR_OUTPUT | IOPORT_INIT_HIGH);
6
  #endif
7
8
void df_init(void) {
9
  
10
  AT45DBX_DEV.id = AT45DBX_CS;
11
  
12
  spi_master_init(&AT45DBX_SPI);
13
  spi_master_setup_device(&AT45DBX_SPI,&AT45DBX_DEV,SPI_MODE_0,AT45DBX_SPI_MASTER_SPEED,0);
14
  spi_enable(&AT45DBX_SPI);
15
  spi_deselect_device(&AT45DBX_SPI,&AT45DBX_DEV);
16
}

Würde mal den Pullup - Spaß weglassen...

MfG

Basti

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.