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.
10 years, 11 months ago.
cannot send signal to rs232
I´ve a problem to put data to serial out and using spi-bus.
This programm makes error: The error-message is: "pinmap not found for peripheral"
**********************
// Reply to a SPI master as slave
#include "mbed.h"
SPISlave device(PA_5, PA_6, PA_7, PA_8); // mosi, miso, sclk, ssel
Serial pc(SERIAL_TX, SERIAL_RX);
int main()
{
int i=1;
// 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
} */
pc.printf ("throwline: %d", i++);
}
}
*****************
When not using the line:
SPISlave device(PA_5, PA_6, PA_7, PA_8); mosi, miso, sclk, ssel
there is no longer this error.
I don´t understand errormessage "pinmap not found for peripheral" in this case.
This is part of enum in PinNames.h:
SERIAL_TX = PA_2, SERIAL_RX = PA_3, USBTX = PA_2, USBRX = PA_3, I2C_SCL = PB_8, I2C_SDA = PB_9, SPI_MOSI = PA_7, SPI_MISO = PA_6, SPI_SCK = PA_5,
Serial_TX and SERIAL_RX are not identical with PA_5-8 used for SPI-communication. What´s wrong in this example to combinate serial-communication with spi?
1 Answer
10 years, 11 months ago.
You have mixed up the pinnames for mosi and sck. Try
SPISlave device(PA_7, PA_6, PA_5, PA_4);
Please use <<code>> and <</code>> tags around your posted code to keep it readable.
Thanks for your help. Ive taken the items from spi-slave-example from web, there´s wrong order , i´ve changed to your example but it also didnt succed. I can only use SPISlave or Serial. Using them together will not succed :-(
Now I tried this:
/// Reply to a SPI master as slave
#include "mbed.h"
SPISlave device(SPI_MOSI, SPI_MISO, SPI_SCK, SPI_CS); // mosi, miso, sclk, ssel
Serial pc(SERIAL_TX, SERIAL_RX);
int main()
{
int i=1;
// 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
} */
pc.printf ("throwline: %d", i++);
}
}
I´ve changed PB_7 to SPI_MOSI and so on, it´s impossible to combinate serial and spiSlave :-(
Now I tried using spi as master and serial:
/// Reply to a SPI master as slave
#include "mbed.h"
// SPISlave device(SPI_MOSI, SPI_MISO, SPI_SCK, SPI_CS); // mosi, miso, sclk, ssel
SPI myspi (SPI_MOSI, SPI_MISO, SPI_SCK);
Serial pc(SERIAL_TX, SERIAL_RX);
int main()
{
...
There´s no problem when using spi as master. but I´d like to use as slave. Is there problem with chipselect pin? Or are there internal problems like using the same interrupts for rxd in serial and cs in spi-mode?
posted by 02 Jan 2015