Hallo,
ich versuche vergeblich die Komunikation zwischen meinem LPC1758 und
einem PN532 NFC Modul zum Laufen zu bringen. Mit Hilfe des SSP
Interfaces und der NXP Library habe ich bereits die SPI-MOSI Verbindung
zum Laufen gebracht.
Leider bekommen ich vom NP532 bis jetzt keine Reaktion auf der MISO
Leitung.
Meine Initialisierung sieht in etwa so aus:
1 |
|
2 | SSP_INIT_STRUC.CPHA = SSP_CPHA_FIRST;
|
3 | SSP_INIT_STRUC.CPOL = SSP_CPOL_HI;
|
4 | SSP_INIT_STRUC.ClockRate = 5000000;
|
5 | SSP_INIT_STRUC.Databit = SSP_DATABIT_8;
|
6 | SSP_INIT_STRUC.Mode = SSP_MASTER_MODE;
|
7 | SSP_INIT_STRUC.FrameFormat = SSP_FRAME_SPI;
|
8 |
|
9 | PINSEL_InitStruct.Funcnum=PINSEL_FUNC_2; //2 SLK
|
10 | PINSEL_InitStruct.OpenDrain=PINSEL_PINMODE_OPENDRAIN; //OPendrain
|
11 | PINSEL_InitStruct.Pinmode=PINSEL_PINMODE_TRISTATE; //tristate
|
12 | PINSEL_InitStruct.Pinnum=PINSEL_PIN_7;
|
13 | PINSEL_InitStruct.Portnum=PINSEL_PORT_0;
|
14 | PINSEL_ConfigPin(&PINSEL_InitStruct);
|
15 |
|
16 | PINSEL_InitStruct.Funcnum=PINSEL_FUNC_2; //2 MISO
|
17 | PINSEL_InitStruct.OpenDrain=PINSEL_PINMODE_NORMAL; //normal
|
18 | PINSEL_InitStruct.Pinmode=PINSEL_PINMODE_TRISTATE;
|
19 | PINSEL_InitStruct.Pinnum=PINSEL_PIN_8;
|
20 | PINSEL_InitStruct.Portnum=PINSEL_PORT_0;
|
21 | PINSEL_ConfigPin(&PINSEL_InitStruct);
|
22 |
|
23 | PINSEL_InitStruct.Funcnum=PINSEL_FUNC_2; //2 MOSI
|
24 | PINSEL_InitStruct.OpenDrain=PINSEL_PINMODE_NORMAL; //normal
|
25 | PINSEL_InitStruct.Pinmode=PINSEL_PINMODE_PULLUP;
|
26 | PINSEL_InitStruct.Pinnum=PINSEL_PIN_9;
|
27 | PINSEL_InitStruct.Portnum=PINSEL_PORT_0;
|
28 | PINSEL_ConfigPin(&PINSEL_InitStruct);
|
29 |
|
30 | PINSEL_InitStruct.Funcnum=PINSEL_FUNC_2; //2 SSEL
|
31 | PINSEL_InitStruct.OpenDrain=PINSEL_PINMODE_NORMAL; //normal
|
32 | PINSEL_InitStruct.Pinmode=PINSEL_PINMODE_PULLUP ;
|
33 | PINSEL_InitStruct.Pinnum=PINSEL_PIN_6;
|
34 | PINSEL_InitStruct.Portnum=PINSEL_PORT_0;
|
35 | PINSEL_ConfigPin(&PINSEL_InitStruct);
|
Und meine Sendeversuche so:
1 | spi_data[0] = (0x00); //preambule
|
2 | spi_data[1] = (0x00); //start
|
3 | spi_data[2] = (0xFF); //start
|
4 | spi_data[3] = (0x06); //packet length
|
5 | spi_data[4] = (0xFA); //checksum
|
6 | spi_data[5] = (0xD4); //tfi
|
7 | spi_data[6] = (0x14); //data
|
8 | spi_data[7] = (0x01); //data
|
9 | spi_data[8] = (0x00); //data
|
10 | spi_data[9] = (0x01); //data
|
11 | spi_data[10] = (0xE9); //dcs
|
12 | spi_data[11] = (0x00); //post
|
13 |
|
14 | for(i = 0; i<12; i++) {
|
15 | SSP_SendData(LPC_SSP1,spi_data[i]);
|
16 | }
|
Außerdem verstehe ich nicht wie man die Checksum berechnet. Im
Usermanualauf Seite 28 heßt es hierzu " 1 Packet Length Checksum LCS
byte that satisfies the relation: Lower byte of [LEN + LCS] = 0x00 "
Vielleicht gibt es ja jemanden, der so etwas ähnliches schon gemacht hat
und mir helfen kann? Ich probier schon den ganzen Tag herum und komme
nicht drauf. Hier noch das Usermanual für den NP532
http://www.nxp.com/documents/user_manual/141520.pdf
danke schon mal für eure Hilfe und mit freundlichen Grüßen