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?