WINC1500 with STM32F407

Go To Last Post
65 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello Everyone smiley,

 

I have purchased WINC1500 module from ELEMENT14 INDIA and designed PCB for the module. I want to interface it with the STm32F407.

As per the ATMEL SPI Porting Guide, I have port the stack on the STM controller. But, it is giving initialization error. Then using the debugger, I found that during initialization, the stack is transmitting following bytes over the SPI :

b[0]=0XCA ;  COMMAND

b[1]=0X00 ;   add>>16

b[2]=0X10 ;   add>>8

b[3]=0X00 ;   add

b[4]=0XCA ;   CRC 7

 

SPI is transmitting the correct bytes serially and it is observed on the CRO.

Stack expects the response from the WIFI module but it gives no response , it gives 0x00.

DESIRED RESPONSE PACKET FROM MODULE : ( 0xCA, 0xF).

 

Kindly suggest me some solution for the above mentioned problem I am facing.

 

Regards

Harwinder

 

Last Edited: Fri. Oct 16, 2015 - 12:22 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

What frequency your SPI is running at? You may want to lower it to like 12 MHz for a start.

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am Using 12Mhz,But i have try other also 8Mhz ,4Mhz,1Mhz,16Mhz but it gives same response.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Then I would look at other pins next, like CE, SS, WAKE.

 

In general, I really have no idea how to debug this.

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Harwinder wrote:
I have purchased WINC1500 module ... and designed PCB for the module.

Before going to a custom PCB, have you got this working on a development/evaluation board?

 

It's always good to start from a known-good system - then, when your custom hardware doesn't work, you can compare & contrast the known-good system.

 

Are you sure you have the correct SPI Mode?

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

yes I used the correct SPI mode (SPI Mode 0) according to datasheet.In atmel studio WINC1500 examples i have seen that they are using SPI mode 0.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Harwinder wrote:
In atmel studio WINC1500 examples i have seen that they are using SPI mode 0.

The trouble with SPI - unlike, say, I2C - is that it has no official definition.

 

So, while is probably safe to assume that Atmel's meaning of "SPI mode 0" is the same as ST's meaning of "SPI mode 0" - that is not guaranteed...

 

See: https://www.avrfreaks.net/comment...

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

 

Quote:

So, while is probably safe to assume that Atmel's meaning of "SPI mode 0" is the same as ST's meaning of "SPI mode 0" - that is not guaranteed...

 

See: https://www.avrfreaks.net/comment/1566616#comment-1566616

I Re conformed that in atmel Example they use CPOL=low,CHPA=low, And i have set the same setting in STM.So there no issue in SPI mode.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

And, similarly, you're sure that Atmel's meanings of "CPOL" and "CHPA" are the same as ST's ?

 

Again, having a known-good reference system would help ...

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Hi Harwinder, i actually have the development kit for the WINC1500 and have some of the examples up and running.

One thing i will point out is that this is a relatively new product and has bugs as i have found.

i have been informed that there is a new version of ASF due out at some stage to address issues which i am waiting on.

There is no API documentation available that i can find as yet.

So maybe there is more you need to do than just send that command and expect an answer.

Where did you get the information from to port your code across to the STM part ?

I would really suggest as awneil suggested that you get a development kit and then you can look at the commands sent and compare to your ported code.

 

Paul

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As rev says, the support for this product is, shall we say, "not fully mature" - even on Atmel's own processors.

And the support does seem to rely upon ASF - which is no help to you.

 

So, unless you have some really solid direct FAE support on this (which doesn't seem to be the case?), I think you may be in for an uphill struggle ...

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You may want to take a look at the Software code used on the ATSAMW25-XPRO for inspiration.

SAMW25 is SAMD21+WINC1500 in a module.

 

Link to ATSAMW25-XPRO board and datasheet:

http://uk.futureelectronics.com/en/Search.aspx?dsNav=Ntk:PartNumberSearch%7catSAMW25%7c1%7c,Ny:True,Nea:True

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

A new version of ASF was released today which solved the issues i have had.

But i noticed there is still no API documentation.

So not sure how you ported your code across.

 

Paul

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

OK Thanks Everyone for your support.i have attached the spi porting guide pdf so please check it.I am going to buy development kit from atmel.After running examples on that i will post the whole code for how to use winc1500 with STM32 or any other MCU.

 

Thanks

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello Harwinder ..

 

can you please share how to use winc1500 with any other MCU? I mean without using the API.

 

Thanks

 

 

All in Time.
 

Last Edited: Thu. Aug 27, 2015 - 11:15 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Hello Everyone,

Finally i have port the winc1500 code to STM mcu. I have attached the full project made in Keil MDK5 for STM32F407 microcontroller.we Port to any mcu by changing only two files.

1:-nm_bsp_samd21.c

2:-nm_bus_wrapper_samd21.c

So please refer to attachment and look how to port and if you have any probelm in porting let me know about that i will try my best to solve it.

Thanks

 

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello Harwinder,

 

Thank you for the project. Please can you send me the détails of the STM32F4 pins used for WINC1500 (INT, SPI, Chip Enable, ...)  on this project

 

Best regards,

Last Edited: Wed. Jan 27, 2016 - 09:19 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

winc Reset =PB1

Chip Select =PB2

IRQN          =PB0

SCK           =PB10

Mosi,miso =PC2,PC3

SS           =PD14

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thankyou. But in your project you are using PA1 PA2 PA3 PE3 PA4 in main.c and PA5 6 7 for spi. Have you a version uptodate ? Thx

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ohh actually you are reading comments in code those are wrong. so please donot read comments see code i had used these pins that i mention in reply.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In fact, I found the use of the PAxx also in the code 

 

void nm_bsp_reset(void)
{
    HAL_GPIO_WritePin(GPIOA,CONF_WINC_PIN_CHIP_ENABLE,GPIO_PIN_RESET);
    HAL_GPIO_WritePin(GPIOA,CONF_WINC_PIN_RESET,GPIO_PIN_RESET);
    nm_bsp_sleep(100);
    HAL_GPIO_WritePin(GPIOA,CONF_WINC_PIN_CHIP_ENABLE,GPIO_PIN_SET);
    nm_bsp_sleep(10);
    HAL_GPIO_WritePin(GPIOA,CONF_WINC_PIN_RESET,GPIO_PIN_SET);
    nm_bsp_sleep(10);

 

Can you share us an uptodate version please ?

 

Thank you

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ya you are right

sorry i get confused b/w 2 codes so now right pins for code that is upload by me is

winc Reset =PA1

Chip Select =PA2

IRQN          =PA0

PA5     ------> SPI1_SCK

  PA6     ------> SPI1_MISO
    PA7     ------> SPI1_MOSI 

SS           =PA3

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you,

 

I Have tested the pinout, the initialization is sussessful but the execution is bloqued on the function wait_for_bootrom :

 

 while(1) {
  reg = nm_read_reg(0x1014); / wait for efuse loading done /
  if (reg & 0x80000000) {
   break;
  }

 

What mean ?

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

it will wait for response from winc1500 module so if you are using debugging then run it it may take some time.use serial terminal to monitor what is going on.and also please write in English i was confused in bootrom.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

thank you

 

Now I have this Debug message 

 

HELLO....(APP)(INFO)Chip ID fff5ffff
main: m2m_wifi_init call error!(-5)

 

I use a STM32F407 Discovery board

 

Why in the beginning of the main, you putted PE3 and PA4 on high level ?

Last Edited: Wed. Jan 27, 2016 - 02:48 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

send me your circuit diagram only then i can tell u about error.

in main i putted PE3 and PA4 on high level  because i am using discovery kit so PE3 is enable pin of some other chip on board so to disable that i putt it high.and PA4 is SS pin so i put it on high so that winc process only valid data.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you,

 

here is a picture of the board STM32F4 Discovery connected to the WINC1500-X-Plained and the used pinout 

 

Thank you

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ok connect VBAT=3V Also and try then and let me know .

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

which VBAT ? on board or Winc ?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

VBAT on winc side to 3V

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sorry, I dont find a VBAT pin on the WINC1500 X Plained Kit

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

try this code with same connections

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Same problem. I obtained on the console the message :

 

ELLO....se read...(00)(APP)(ERR)[spi_data_read][379][nmi spi]: Failed data response read...(00)
(APP)(ERR)[spi_read_reg][619][nmi spi]: Failed data read...
(APP)(ERR)[spi_data_read][379][nmi spi]: Failed data response read...(00)
(APP)(ERR)[spi_read_reg][619][nmi spi]: Failed data read...
.........

.......

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It means your connection are not correct so recheck ur connection by multimeter this code is working for me for for same hardware

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

thank you very much! this topic is what I'm looking for,

 

Do you try this with Xplained module? or just ATWINC1500 with your own schemetic?

 

If you using Xplained module, where do you connect the ID pin? No connect? or VCC, GND, or another GPIO?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In your picture, PA4 has connection(must have no connection) & PA0(must connect to IRQ) has no connection, I think you have a wrong connection.

Last Edited: Thu. Feb 4, 2016 - 06:17 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

how could you get that message? From uart?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello

 

finally the WINC1500Xplained works  on STM32L476 :)

 

I have used the same code of Harwinder and I have only changed the SPI Baudrate Prescalar to 256

 

Thank you Harwinder for your help :)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

you mean this one?

 

hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_4;

 

4 to 256?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi everyone,

 

I am trying to use winc1500 with STM32f429I-disco kit . 

But I am not able to read CHIP id. I am getting error same as above.

 

"HELLO....(APP)(INFO)Chip ID fff5ffff
main: m2m_wifi_init call error!(-5)
"

 

Does any one help me here?

 

I have configured following pins for my board.

SPI4 

SCK--> PE2

NSS --> PE4

MISO--> PE5

MOSI --> PE6

 

Wake --> PF3

IRQ--> PF2

Chip enable --> PF5

Reset --> PF6

 

I trying to use "Harwinder" 's code for my reference. 

Thanks for your time.

--Regards,

Meet Shah

 

 

--
Regards,
Meet Shah

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

HELLO 

can you upload your project in file .Zip, for see what are you did :) 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

   hi Harwinder i need your helps! 

i make a connection between a STM32f427 and WINC1500, i used your programme( i juste changed pins)! 

 

in initialisation "ret = m2m_wifi_init(&param)" , ret is != to M2M_SUCCESS, i don't know who are my problem 

if (M2M_SUCCESS != ret) {
        printf("main: m2m_wifi_init call error!(%d)\r\n", ret);
        while (1) {
        }
    }

 

thanks ! 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

for more precision my problem is here: 

    /* Apply device specific initialization. */
    ret = nm_drv_init(NULL);
    if(ret != M2M_SUCCESS)     goto _EXIT0;

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

my Ret value is matched here :     

 

if(strtmp.u8FirmwareMajor != M2M_DRIVER_VERSION_MAJOR_NO
            || strtmp.u8FirmwareMinor != M2M_DRIVER_VERSION_MINOR_NO)
    {
        ret = M2M_ERR_FW_VER_MISMATCH;
        M2M_ERR("Firmware version mismatch!\n");
    }

 

in this case Ret= -13, this is an error! 

 

someone can explain me what means! 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi, please I want to know how you solved the problem of receiving 0x00 all the time? Thanks

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello, I've recompiled the Atmel library for a cortex M3 STM32F100, with the Atollic Truestudio.

It's the temperature demo, so the sockets are working.

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello,

 

I'm working with ATWINC1500 module and STM32F103ZETb MCU. I have ported nm_bsp_samd21.c and nm_bus_wrapper_samd21.c to my MCU, and proved that the firmware is communicating correctly through the SPI interface. But when I've started with the software that ATmel provides, I have a problem in the wait_for_bootrom function, because I never reach the register to be 0x80000000 so I can't break from the loop. I mean this piece of code:

 

while(1) {
        reg = nm_read_reg(0x1014);    /* wait for efuse loading done */
        if (reg & 0x80000000) {
            break;
        }
        nm_bsp_sleep(1); /* TODO: Why bus error if this delay is not here. */
    }

 

I have looked to the code you provide and use it with the MCU you use, and it works, I have compared to my code but I'm not able to find the error. Does anybody know which can be the problem for that and how to resolve?

 

Thank you very much beforehand,

Goiatz

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello everybody,

 

does anybody know the maximum UDP streaming data rate that can be achieved with Atmel's WINC1500 API?

I just achieve about 200kbps (Host MCU: 80Mhz main-clock, 40Mhz SPI-clock).

 

And it is possible to disable the green LED from winc1500 xplained pro extension board by host MCU?

 

Thanks for help,

Thinu

Last Edited: Sun. Feb 26, 2017 - 07:10 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello sir, where did you find the code such as "nm_bsp_samd21.c ". I can't find it on the website. Would you please share the information to me?  Thank you.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello, everyone,

 

This post literally saved my life, in my current work I must port the code from ATWIN1500C to STM32F04 Discovery board but I am having a lot of trouble doing it, from tomorrow on I am going to use the code which was supplied here.

Thought I still have a question, during the last weeks I have been working restlessly on porting the code I am using STM32F04 Discovery and System Workbench and I can't go forward and get the code to compile. First I created a project in StmCube than using this base I imported all files to System Workbench Project and tried to correct all the errors especially related to the indexer.

 

What was the procedure that you used to get the code working? Which steps?

 

Thank you, everyone, for your help.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Goiatz wrote:

Hello,

 

I'm working with ATWINC1500 module and STM32F103ZETb MCU. I have ported nm_bsp_samd21.c and nm_bus_wrapper_samd21.c to my MCU, and proved that the firmware is communicating correctly through the SPI interface. But when I've started with the software that ATmel provides, I have a problem in the wait_for_bootrom function, because I never reach the register to be 0x80000000 so I can't break from the loop. I mean this piece of code:

 

while(1) {
        reg = nm_read_reg(0x1014);    /* wait for efuse loading done */
        if (reg & 0x80000000) {
            break;
        }
        nm_bsp_sleep(1); /* TODO: Why bus error if this delay is not here. */
    }

 

I have looked to the code you provide and use it with the MCU you use, and it works, I have compared to my code but I'm not able to find the error. Does anybody know which can be the problem for that and how to resolve?

 

Thank you very much beforehand,

Goiatz

Hi Goiatz

I have the same problem with PIC32 MCU, how did you solve it?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello s.fiore,

I had also the same problem as many people here with the wait_for_bootrom function. For me it looks like that sometimes the firmware gets in a state of error in the and is not able to perform a reset by software so it hangs forever in this loop.

My solution was to add a reset througt the reset pin in the and considerably increase the sleep times.

 

by the way I have also here the Adafruit shield for the ATWINC1500 adafruit provides some libraries to operate the shield and in their library the sleep time of the reset function is considerably bigger.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Note that the last post in this thread, before s.fiore resurrected it, was one year ago - so it is unlikely that that the original posters are still listening!

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Erick1989 wrote:

Hello, everyone,

 

This post literally saved my life, in my current work I must port the code from ATWIN1500C to STM32F04 Discovery board but I am having a lot of trouble doing it, from tomorrow on I am going to use the code which was supplied here.

Thought I still have a question, during the last weeks I have been working restlessly on porting the code I am using STM32F04 Discovery and System Workbench and I can't go forward and get the code to compile. First I created a project in StmCube than using this base I imported all files to System Workbench Project and tried to correct all the errors especially related to the indexer.

 

What was the procedure that you used to get the code working? Which steps?

 

Thank you, everyone, for your help.


Thank you Erick,

Did you only increase the duration of the nm_bsp_reset () function?

Did you insert some more reset than that within the nm_bsp_init () function?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I did increased the nm_bsp_reset() time and I also insert the reset function in other places, unfortunatelly I do not have time to look for it preciselly now.

I recall that after unsucessful SPI initialization the master, your mcu, only received the same byte sequence no matter what you sent to the SPI than the software after some tries branches to a reset command thought SPI bus.

Just under this reset using SPI I insert a nm_bsp_reset() and a sleep function after that I was not able to cause the problem again.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello All,

 

I have SPI bus error issue in WINC1500 + NUCELO_F429ZI board, It reads the chip ID firmware version correctly. but Write block is failed while sending the connect command. I have connected using the Jumper wires with WINC1500 XPRO board and NUCLEO_F429ZI board.

 

Please advice on this issue, I stuck here. 

 

Console Log:

System clock by default 180 MHz 

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

Chip ID 1503a0
Firmware ver   : 255.6.0 Svnrev 16368
Firmware Build Apr  6 2018 Time 17:16:54
Firmware Min driver ver : 19.3.0
Driver ver: 19.5.4
Driver built at Jun 27 2018     16:21:07
main: m2m_wifi_init call error!(-6) --> -6 stands for Bus error.

 

 

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

void nm_bus_wifi_spi_init(SPI_HandleTypeDef *hspi)

{

    GPIO_InitTypeDef  GPIO_InitStruct;

 

    /* Peripheral clock enable */

    SPI_WIFI_CLK_ENABLE();

 

    /* Configure GPIO pin : PA4 - we are using ST GPIO definitions for winc1500 */

    GPIO_InitStruct.Pin   = SPI_WIFI_CS_PIN;

    GPIO_InitStruct.Mode  = GPIO_MODE_OUTPUT_PP;

    GPIO_InitStruct.Pull  = GPIO_PULLUP;

    GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;

    GPIO_InitStruct.Alternate = 0;

    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

    HAL_GPIO_WritePin(SPI_WIFI_CS_GPIO_PORT,SPI_WIFI_CS_PIN,GPIO_PIN_SET);

 

    /**SPIx GPIO Configuration

    PB3     ------> SPI_WIFI_SCK

    PB4     ------> SPI_WIFI_MISO

    PB5     ------> SPI_WIFI_MOSI

    */

    GPIO_InitStruct.Pin = SPI_WIFI_SCK_PIN|SPI_WIFI_MISO_PIN|SPI_WIFI_MOSI_PIN;

    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

    GPIO_InitStruct.Pull = GPIO_PULLDOWN;

    GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;

   GPIO_InitStruct.Alternate = SPI3_WIFI_AF;

    HAL_GPIO_Init(SPI_WIFI_MOSI_GPIO_PORT, &GPIO_InitStruct);

}

 

 

/*

* @fn nm_bus_init

* @brief Initialize the bus wrapper

* @return M2M_SUCCESS in case of success and M2M_ERR_BUS_FAIL in case of failure

*/

sint8 nm_bus_init(void *pvinit)

{

sint8 result = M2M_SUCCESS;

 

/* WiFi SPI init function - called from nm_bus_init() */

 

hspiWifi.Instance    = SPI_WIFI;

hspiWifi.Init.Mode    = SPI_MODE_MASTER;

hspiWifi.Init.Direction    = SPI_DIRECTION_2LINES;

hspiWifi.Init.DataSize    = SPI_DATASIZE_8BIT;

hspiWifi.Init.CLKPolarity    = SPI_POLARITY_LOW;

hspiWifi.Init.CLKPhase    = SPI_PHASE_1EDGE;

hspiWifi.Init.NSS    = SPI_NSS_SOFT;

hspiWifi.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_16;

hspiWifi.Init.FirstBit    = SPI_FIRSTBIT_MSB;

hspiWifi.Init.TIMode    = SPI_TIMODE_DISABLE;

hspiWifi.Init.CRCCalculation   = SPI_CRCCALCULATION_DISABLE;

hspiWifi.Init.CRCPolynomial    = 10;

//   hspiWifi.Init.CRCLength = SPI_CRC_LENGTH_DATASIZE;

//   hspiWifi.Init.NSSPMode = SPI_NSS_PULSE_DISABLE;

if (HAL_SPI_Init(&hspiWifi) != HAL_OK)

{

M2M_ERR("SPI bus Initialization error\r\n");

}

 

HAL_SPI_MspInit(&hspiWifi);

return result;

}

 

 

 

 

 

 

Saravana

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi everyone,

 

I'm aware that this thread is inactive but I'm hoping that someone with some knowledge of this may read this. I'm attempting to use the WINC1500 with an STM32F7 board and cannot get the winc chip to respond. The problem I have is that wait_for_bootrom() is never terminating because spi_read_reg in nmspi.c is failing to read a response. I can see that the single read command is being sent, and the response command is also being sent. When it tries to read the response in spi_data_read(), the code is never finding the response header. I can see that the loop is looking for a byte beginning with 0xF, however the response I am getting is 0x20. Due to this, the do-while loop is exiting after retry hits zero and the message "[mni spi]: Failed data response read...(%02x)" is being shown.

 

I am using the same spi settings as the ones used in the code posted by Harwinder. I have replaced the HAL library files with the equivalent stm32f7xx files.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi sir,

i want to interface ATWINC3400  wifi/ble module with host STM32H7 ,using uart and spi i have interfaced but host application code is developing using KEIL

how do i  import ATWINC3400 libraries and driver code from atmel studio  to keil 

 

 

Thanks

 

 

Last Edited: Thu. Nov 14, 2019 - 09:32 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I would suggest you download the latest ASF 3.47.0 first. The WINC3400 driver is in <common\components\wifi\winc3400\wifi_drv> folder. APIs you need to port for your hardware are in the <bsp\source> and <bus_wrapper\source> folders. The goal is to provide equivalent functions listed in nm_bsp.h and nm_bus_wrapper.h for your hardware.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hii harwinder

 

      i have been trying to port the ATWinc3400 wifi code to stm32h7 controller. i downloaded the ASF 3.47 and trying to port.

  1)how to port and which files need to add 

 

Please provide any reference to port

 

Thanks

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello sir,

    I am working on ATWINC3400 Module with STM32H753IIT6 board and I am facing the same issue that execution is blocked in wait_for_bootrom can you please tell me how you solved that issue so it will be helpful for me. 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello,

 I am working with WINC3400 module and interface with STM32H753IIT6 facing the same issue of bootrom can you please tell how you solved that it will be helpful for me.

 

Thank You.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hello

If the voltage of the Battery input is too low, you see this same problem

Hans T

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Just a heads up ... when you buy a module you don't know what version firmware/driver it has.  It is important to change the macro definitions on this example code so they satisfy this comparison:

 

    ret = nm_get_firmware_info(&strtmp);

    M2M_INFO("Firmware ver   : %u.%u.%u\n", strtmp.u8FirmwareMajor, strtmp.u8FirmwareMinor, strtmp.u8FirmwarePatch);
    M2M_INFO("Min driver ver : %u.%u.%u\n", strtmp.u8DriverMajor, strtmp.u8DriverMinor, strtmp.u8DriverPatch);
    M2M_INFO("Curr driver ver: %u.%u.%u\n", M2M_DRIVER_VERSION_MAJOR_NO, M2M_DRIVER_VERSION_MINOR_NO, M2M_DRIVER_VERSION_PATCH_NO);

    if(strtmp.u8FirmwareMajor != M2M_DRIVER_VERSION_MAJOR_NO
            || strtmp.u8FirmwareMinor != M2M_DRIVER_VERSION_MINOR_NO)
    {
        ret = M2M_ERR_FW_VER_MISMATCH;
        M2M_ERR("Firmware version mismatch!\n");
    }
    return ret;
 

Otherwise the code will get stuck there.  This is in nmdrv.c file [nm_drv_init() function].  In my case one was 19.3 and the other was 19.5 so I spent a little time debugging, setting breakpoints, before I was able to figure it out.

 

I ported the example by Harwinder Wifi_Scan_ex.c to STM32L4A6 (or L496) MCU and it works.  I use a NUCLEO-L4A6ZG dev board.

 

I've attached the zip file here.  Download STM32CubeL4_v1-17-0_v1.17.0 SDK and unzip it.  Download MDK (ARM Keil) 5.36 and install it.

Go to this folder and unzip it there:

..\en.stm32cubel4_v1-17-0_v1.17.0\STM32Cube_FW_L4_V1.17.0\Projects\NUCLEO-L496ZG\Examples\GPIO

 

Have fun!

 

Gil

Attachment(s):