Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

W5500 Tcpwrite hang

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> EASY TCP/IP
View previous topic :: View next topic  
Author Message
amir.eshraghi@aii1.com

Bascom Member



Joined: 06 Sep 2019
Posts: 5

PostPosted: Fri Dec 03, 2021 1:50 am    Post subject: W5500 Tcpwrite hang Reply with quote

Hi

When I run sample code of W5200 client it work find but when I run with my code(exact same code) which use interrupts, and many other stuff it hangs at
Code:
[Result = Tcpwrite(idx , "Hello from W5200A{013}{010}")  ]
or it send junk,.

for example:

Code:
Result = Tcpwrite(idx , "r")


or it hangs , or send you junk variable.

I have no clue what is causing this . Does easy Tcpwrite using specific timer or interrupt that I am using too. (I only use external interrupt every one second).

Please let me know if you have any questions.

Code:
[                                                 '-----------------------------------------------------------------------------------------
'name                     : dhcp_W5500.bas
'copyright                : (c) 1995-2017, MCS Electronics. Based on dhcp.bas from Atilio Mosca
'purpose                  : demo: DHCP
'micro                    : Mega88
'suited for demo          : no
'commercial addon needed  : only hardware
'-----------------------------------------------------------------------------------------
$regfile = "M2560def.dat"                                   'ATMEGA2560 (TQFP)
$crystal = 7372800                                          'oscillator speed (MHz)
Config Clockdiv = 1                                         'clock divider
Config Clock = User                                         'use compiler time functions w/ user set time & date
$loadersize = 4096
$hwstack = 200                                              'hardware stack size (30)
$swstack = 200                                              'software stack size (51)
$framesize = 2000                                           'frame size (1419)
'$lib "stackcheck.lib"

     $baud = 19200                                               ' use baud rate


$hwstack = 128                                              ' default use 32 for the hardware stack
$swstack = 128                                              ' default use 10 for the SW stack
$framesize = 128                                            ' default use 40 for the frame space
Declare Function Xidcookie_ok() As Byte
Declare Function Parse_dhcp_msg(byval Doption As Byte) As Byte
Declare Function Dhcp_ok() As Byte
Declare Sub Print_parse()



Dim Mac_add(6) As Byte

                       ' result


Tcp_cs Alias Porth.3 : Set Tcp_cs                           'Ethernet chip select
status Alias portd.6 : Set status

  reset status

'This number should match the one in the 'Config Tcpip...' line
'Do not use first byte
Mac_add(1) = 0
Mac_add(2) = 128
Mac_add(3) = 12
Mac_add(4) = 34
Mac_add(5) = 56
Mac_add(6) = 78

  Config Spi = Hard , Interrupt = Off , Data Order = Msb , Master = Yes , Polarity = High , Phase = 1 , Clockrate = 4 , Noss = 0
  Spsr = 1
  Spiinit

'Print "Init , set IP to 192.168.1.70"                       ' display a message
Config Tcpip = Noint , Mac = Mac_add(1) , Ip = 10.0.16.56 , Submask = 255.255.255.0 , Gateway = 10.0.16.254 , Localport = 1000 , Chip = W5500 , Spi = 1 , Cs = Tcp_cs


   Dim Bclient As Byte                                         ' socket number
Dim Idx As Byte
Dim Result As Word , Result2 As Word    , Result3 As Word                    ' result
Dim S As String * 80
Dim Flags As Byte
Dim Peer As Long
Dim L As Long



Do
  Waitms 1000
  For Idx = 0 To 3
     Result = Socketstat(idx , 0)                           ' get status
     Select Case Result
       Case Sock_established
            If Flags.idx = 0 Then                           ' if we did not send a welcome message yet
               Flags.idx = 1
               Result = Tcpwrite(idx , "Hello from W5200A{013}{010}")       ' send welcome
            End If
            Result = Socketstat(idx , Sel_recv)             ' get number of bytes waiting

            If Result > 0 Then
            Result3 = Tcpwrite(idx , "Hello")
               Do
                  Result3 = Tcpwrite(idx , "here")
                  set status
                 Result = Tcpread(idx , S)
                 reset status
                  Result3 = Tcpwrite(idx , "Pass")



                 If Lcase(s) = "exit" Then
                    Result2 = Tcpwrite(idx , "exit" )
                 Elseif Lcase(s) = "time" Then
                    Result2 = Tcpwrite(idx , "12:00:00{013}{010}")       ' you should send date$ or time$

                 End If
               Loop Until Result = 0
            End If
       Case Sock_close_wait

            Closesocket Idx
       Case Sock_closed

            Bclient = Getsocket(idx , Sock_stream , 5000 , 0)       ' get socket for server mode, specify port 5000


            Socketlisten Idx
           ' Print "Result " ; Result
            Flags.idx = 0                                   ' reset the hello message flag


     End Select
  Next   Idx
Loop



End]
[/code]
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5920
Location: Holland

blank.gif
PostPosted: Sat Dec 04, 2021 11:32 am    Post subject: Reply with quote

you best clean up the sample it has multiple $hwstack for example.

from the help ; W5500 only supports the NOINT option.

_________________
Mark
Back to top
View user's profile Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> EASY TCP/IP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum