Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
9 years, 1 month ago.
LPC4088 Problem with SPISlave/SPI
Hello,
I tried to implement the SPISlave to my LPC4088. For the start i used the example programm but unfortunetly i just got all my LEDs blinking on the board after loading the programm to mit board.
CODE Reply to a SPI master as slave
- include "mbed.h"
SPISlave device(p5, p6, p7, p8); mosi, miso, sclk, ssel
int main() { device.reply(0x00); Prime SPI with first reply while(1) { if(device.receive()) { int v = device.read(); Read byte from master v = (v + 1) % 0x100; Add one to it, modulo 256 device.reply(v); Make this the next reply } } }
I use an other LPC4088 QSB as a Master Device. While loading the example Code from mbed to the Board, an other problem occured. Only the LED3&LED4 lighted up, but dimmed, and nothing more happend.
Does anyone has a suggestion to solve the problem ?
1 Answer
9 years, 1 month ago.
Please use <<code>> and <</code>>
tags around your posted code to keep it readable.
Blinking LEDs usually indicate that you have used a wrong pinmapping. In this case that is caused by the mapping of the SSEL. The SPI slave needs a specific pin for SSEL that matches the SPI peripheral that you use. In your case SPI0 is connected to p5,p6,p7. You need to map SSEL on p0_16,P,1_21, P1_28 or P2_23 as shown in the table below. Check the hardware docs to find out which external pin matches any of these. I dont think it is any of the p1..px pins.
static const PinMap PinMap_SPI_SCLK[] = { {P0_7 , SPI_1, 2}, {P0_15, SPI_0, 2}, {P1_0, SPI_2, 4}, {P1_19, SPI_1, 5}, {P1_20, SPI_0, 5}, {P1_31, SPI_1, 2}, {P2_22, SPI_0, 2}, {P4_20, SPI_1, 3}, {P5_2, SPI_2, 2}, {NC , NC , 0} }; static const PinMap PinMap_SPI_MOSI[] = { {P0_9 , SPI_1, 2}, {P0_13, SPI_1, 2}, {P0_18, SPI_0, 2}, {P1_1, SPI_2, 4}, {P1_22, SPI_1, 5}, {P1_24, SPI_0, 5}, {P2_27, SPI_0, 2}, {P4_23, SPI_1, 3}, {P5_0, SPI_2, 2}, {NC , NC , 0} }; static const PinMap PinMap_SPI_MISO[] = { {P0_8 , SPI_1, 2}, {P0_12, SPI_1, 2}, {P0_17, SPI_0, 2}, {P1_4, SPI_2, 4}, {P1_18, SPI_1, 5}, {P1_23, SPI_0, 5}, {P2_26, SPI_0, 2}, {P4_22, SPI_1, 3}, {P5_1, SPI_2, 2}, {NC , NC , 0} }; static const PinMap PinMap_SPI_SSEL[] = { {P0_6 , SPI_1, 2}, {P0_14, SPI_1, 2}, {P0_16, SPI_0, 2}, {P1_8, SPI_2, 4}, {P1_21, SPI_0, 3}, {P1_26, SPI_1, 5}, {P1_28, SPI_0, 5}, {P2_23, SPI_0, 2}, {P4_21, SPI_1, 3}, {NC , NC , 0} };