ESP8266 Developer Zone The Official ESP8266 Forum 2020-03-14T08:48:36+08:00 https://bbs.espressif.com:443/feed.php?f=31&t=1346 2020-03-14T08:48:36+08:00 2020-03-14T08:48:36+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1346&p=74259#p74259 <![CDATA[ESP8266 SPI as slave]]> Statistics: Posted by KeithSkync — Sat Mar 14, 2020 8:48 am


]]>
2019-01-06T07:40:21+08:00 2019-01-06T07:40:21+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1346&p=36603#p36603 <![CDATA[ESP8266 SPI as slave]]>
I’ve been doing some work with a new product using a few pics and I need usb support adding so I’ve added another pic and have a selection of lines between them

unfortunately I’m stuck with general purpose i/o lines on the master pic but the slave usb pic has hardware spi lines available

I’ve been trying to use the hardware spi in slave mode without a great deal of consistent success I can transmit to the slave just fine but I cant seem to recover any real data from it,

Has anyone tried this or can anyone suggest another way of sending packets of byte between 2 pics,

Bear in mind that both pics are using interrupts and the usarts are not available on the master.

Any suggestions?


Master = 4550 but could be a different one
Slave is 2550

Master name slave
A.0 nspisel B.4
A.3 spiclk B.1
C.6 miso C.7
B.0 mosi B.0
B.1 slave busy B.3


thanks in advance

Richard

Statistics: Posted by Guest — Sun Jan 06, 2019 7:40 am


]]>
2018-10-14T05:51:01+08:00 2018-10-14T05:51:01+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1346&p=33600#p33600 <![CDATA[ESP8266 SPI as slave]]> Statistics: Posted by Guest — Sun Oct 14, 2018 5:51 am


]]>
2017-05-03T12:58:39+08:00 2017-05-03T12:58:39+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1346&p=12747#p12747 <![CDATA[ESP8266 SPI as slave]]> this is my code but its not succes ...

MASTER:
void initSPI_Master
DDRB = 1<<21<<31<<5; // SCK, MOSI dan SS menjadi output
DDRB &= 1<<4; // MISO menjadi input
SPCR = 1<<MSTR; // SPI sebagai master
SPCR = 1<<SPR01<<SPR1; // Pembagi clock = 128
SPCR = 1<<SPE; // Aktifkan SPI

void setup
initSPI_Master;
Serial.begin9600;
pinMode2, INPUT;pinMode3, INPUT; pinMode4, INPUT;
digitalWrite2,HIGH;digitalWrite3, HIGH; digitalWrite4, HIGH;

void loop
//char adc = StringanalogRead0, DEC;
int adc=analogReadA0;
ifdigitalRead2==LOW
kirimData5;
else ifdigitalRead3==LOW
kirimData10;
else ifdigitalRead4==LOW
kirimDataadc;
Serial.printadc;


void kirimDatachar data
SPDR = data; // Kirim data
whileSPSR & 1<<SPIF; // Tunggu sampai pengiriman
delay500;



SLAVE:

unsigned char data;
void initSPI_Slave
DDRB &= 1<<21<<31<<5; // SCK, MOSI dan SS menjadi input
DDRB = 1<<4; // MISO menjadi output
SPCR &= 1<<MSTR; // SPI sebagai slave
SPCR = 1<<SPR01<<SPR1; // Pembagi clock = 128
SPCR = 1<<SPE; // Aktifkan SPI

void setup
initSPI_Slave;
Serial.begin9600;

void loop
whileSPSR & 1<<SPIF; // Tunggu data masuk
data = SPDR;

// Menyimpan isi register SPDR ke variabel data
Serial.println"Data Receive ==> ";
Serial.printlndata,HEX;
delay1000;

<a href=http://sale-discounts.com/>купоны акции</a>

Statistics: Posted by RiliyVax — Wed May 03, 2017 12:58 pm


]]>
2017-02-18T01:36:38+08:00 2017-02-18T01:36:38+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1346&p=11340#p11340 <![CDATA[Re: [ESP8266] SPI as slave]]>
ESP_Faye wrote:
The attachment is a demo of SPI running as slave based on ESP8266_NONOS_SDK.

If using ESP8266_NONOS_SDK_V1.5.0 or later version, please add "-lcrypto" in 'LINKFLAGS_eagle.app.v6" area of the Makefile.

Documentation about SPI

附件为基于 ESP8266_NONOS_SDK 的 SPI slave 示例。

如果使用 ESP8266_NONOS_SDK_V1.5.0 或之后版本,请在示例的 Makefile 中 'LINKFLAGS_eagle.app.v6" 区域增加 "-lcrypto" 。

SPI 文档下载

Thanks for your interest in ESP8266 !


Hi,

I have one requirement in which ESP32 becomes as SPI Slave device for some communication with Master SPI device.

Also, We have e already started Development using ESP8266 RTOS SDK and I have checked in driver folder that Espressif Systems has not released SPI driver officially for RTOS SDK.

So, do you have any idea or sample SPI Slave driver with sample code? Does NONOS SPI driver can be ported and used into RTOS SDK?

Let me know for this ASAP as we have quick requirement for this for our project.

Regards,
Ritesh Prajapati

Statistics: Posted by ritesh — Sat Feb 18, 2017 1:36 am


]]>
2016-06-07T16:14:42+08:00 2016-06-07T16:14:42+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1346&p=7242#p7242 <![CDATA[Re: [ESP8266] SPI as slave,]]>
this is what i got:
Image

yellow line is SPI_SCLK, blue line is MOSI (i changed spi clk to 625khz)

when i zoom into the "mass" of the yellow line:
Image
the freq is happened to match the core clk(80MHZ)

No doubt, with this clock waveform, the slave device won't work!

Lucky for me, i found this post: viewtopic.php?f=7&t=1342&p=7241&hilit=hspi+clock#p7241

I then add this line to my code:
WRITE_PERI_REG(PERIPHS_IO_MUX, 0x005);
IT WORKS!

I read out the original PERIPHS_IO_MUX register:
it is : 0x205.
however I can't find a detail description of this register, especially bit above 7.

can @Espressif_Faye give us a description about this ? does this line is necessary or have other way,do it have any side effect?
we're doing some serious RD on 8266, using unknown code is dangerous!


------------------------

Code:

void user_init(void)
{
    os_printf("SDK version:%s\n", system_get_sdk_version());

   os_printf("------------------start------------------\n\r");

   set_data();   
   spi_master_init(HSPI);
   spi_mast_byte_write(HSPI,0xAA);

   GPIO_OUTPUT_SET(GPIO_ID_PIN(5), 1);
   
   //spi_byte_write_espslave(HSPI,0xAA);

   //spi_WR_espslave(HSPI);
   
   //spi_WR_espslave(HSPI);
   
      
   os_printf("------------------done!------------------\n\r");
   os_printf("\n\r");
   os_printf("\n\r");


   
   
}
   




Code:

void ICACHE_FLASH_ATTR
    spi_master_init(uint8 spi_no)
{
   uint32 regvalue;

   if(spi_no>1) {   

      os_printf("invalid spi number!\n\r");

      return;

   } //handle invalid input number
    else if(spi_no==SPI){
        PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_CLK_U, 1);//configure io to spi mode
        PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_CMD_U, 1);//configure io to spi mode   
        PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_DATA0_U, 1);//configure io to spi mode   
        PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_DATA1_U, 1);//configure io to spi mode   
    }else if(spi_no==HSPI){
       os_printf("spi_clk HSPI %08x\r\n",READ_PERI_REG(PERIPHS_IO_MUX));
       //WRITE_PERI_REG(PERIPHS_IO_MUX, 0x001);
        PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDI_U, 2);//configure io to Hspi mode
        PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTCK_U, 2);//configure io to Hspi mode   
        PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTMS_U, 2);//configure io to Hspi mode   
        PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDO_U, 2);//configure io to Hspi mode   
    }

   
   //SET_PERI_REG_MASK(SPI_USER(spi_no), SPI_CS_SETUP|SPI_CS_HOLD);
   //CLEAR_PERI_REG_MASK(SPI_USER(spi_no), SPI_FLASH_MODE|SPI_USR_COMMAND);

   SET_PERI_REG_MASK(SPI_USER(spi_no), SPI_CS_SETUP|SPI_CS_HOLD|SPI_USR_COMMAND);
   CLEAR_PERI_REG_MASK(SPI_USER(spi_no), SPI_FLASH_MODE);

   WRITE_PERI_REG(SPI_CLOCK(spi_no),
               ((1&SPI_CLKDIV_PRE)<<SPI_CLKDIV_PRE_S)|
               ((63&SPI_CLKCNT_N)<<SPI_CLKCNT_N_S)|
               ((31&SPI_CLKCNT_H)<<SPI_CLKCNT_H_S)|
               ((63&SPI_CLKCNT_L)<<SPI_CLKCNT_L_S)); //clear bit 31,set SPI clock div
               
   os_printf("spi_clk HSPI %08x\r\n",READ_PERI_REG(SPI_CLOCK(spi_no)));



   //WRITE_PERI_REG(PERIPHS_IO_MUX_MTDO_U, READ_PERI_REG(PERIPHS_IO_MUX_MTDO_U) & 0x7F);

   os_printf("spi_clk SPI %08x\r\n",READ_PERI_REG(SPI_CLOCK(SPI)));
   os_printf("MTMO %08x\r\n", READ_PERI_REG(PERIPHS_IO_MUX_MTDO_U));

Statistics: Posted by foxxml — Tue Jun 07, 2016 4:14 pm


]]>
2015-11-05T17:11:04+08:00 2015-11-05T17:11:04+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1346&p=4465#p4465 <![CDATA[[ESP8266] SPI as slave]]>
If using ESP8266_NONOS_SDK_V1.5.0 or later version, please add "-lcrypto" in 'LINKFLAGS_eagle.app.v6" area of the Makefile.

Documentation about SPI

附件为基于 ESP8266_NONOS_SDK 的 SPI slave 示例。

如果使用 ESP8266_NONOS_SDK_V1.5.0 或之后版本,请在示例的 Makefile 中 'LINKFLAGS_eagle.app.v6" 区域增加 "-lcrypto" 。

SPI 文档下载

Thanks for your interest in ESP8266 !
SPI as slave.zip

Statistics: Posted by ESP_Faye — Thu Nov 05, 2015 5:11 pm


]]>