Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Probelm with Udpwrite in Bootloader with XMEGA

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
christian_B97

Bascom Member



Joined: 16 Oct 2015
Posts: 2

PostPosted: Fri Nov 27, 2020 8:31 pm    Post subject: Probelm with Udpwrite in Bootloader with XMEGA Reply with quote

Hey guys,

i have following Problem with my Code:

I created a Bootloader for ATMEGA644 and reuse the Code (with little Changes) for the XMEGA128A4AU.

Without " $Loader = &H10000 " all works as expected, my W5500 Module gets an IP via DHCP as on my ATMega644 Modules, but after adding " $Loader = &H10000 " the uC seems to have a Problem with

Code:
Result = Udpwrite(255.255.255.255 , 67 , 0 , Tt(1) , 548 )


The uC will never execute the next Line in the Source wich is a print. In Wireshark the Packet is not recived, so i think it is not sent by the W5500. Maybe theres an Problem with SPI or with the TCP/IP in the Bootloader?
As the TCP/IP worked with the ATMEGA very good, i think its an Problem with SPI and the Bootloader?


Code:
Config Spic = Hard,  Data_Order = Msb, Master = Yes, Mode = 0 , CLOCKDIV = CLK16, SS = AUTO
Open "Spic" For Binary As #10

Reset PortC.1     '
Waitms 200
Set PortC.1    
Waitms 200

Config Tcpip = Noint , Mac = Mac_add(1) , Ip = 0.0.0.0 , Submask = 0.0.0.0 , Gateway = 0.0.0.0 , Localport = 68 , SPI = SPIC ,  Chip = W5500 , Cs = PortC.4


Would be nice if someone could help me with that, the only idea i have right now is to compare SPI output with $Loader and without.

Best Regards
Chris

(BASCOM-AVR version : 2.0.8.2 , Latest : 2.0.8.3 )
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5921
Location: Holland

blank.gif
PostPosted: Mon Nov 30, 2020 3:46 pm    Post subject: Reply with quote

it is always best to first check with the latest version.
for xmega there is a sample :

Code:

'-----------------------------------------------------------------------------------------
'name                     : TCPCONNECT_W5500.bas
'copyright                : (c) 1995-2020, MCS Electronics
'purpose                  : test SOCKETCONNECT() function
'micro                    : xMega64A3
'suited for demo          : no, needs library only included in the full version
'commercial addon needed  : no
'-----------------------------------------------------------------------------------------

$regfile = "xm64a3def.dat"
$crystal = 32000000
$hwstack = 64                                               ' default use 32 for the hardware stack
$swstack = 128                                              'default use 10 for the SW stack
$framesize = 64                                             'default use 40 for the frame space

'First Enable The Osc Of Your Choice
Config Osc = Enabled , 32mhzosc = Enabled
'configure the systemclock
Config Sysclock = 32mhz , Prescalea = 1 , Prescalebc = 1_1
'configure UART
Config Com1 = 19200 , Mode = Asynchroneous , Parity = None , Stopbits = 1 , Databits = 8


Config Spie = Hard , Master = Yes , Mode = 0 , Clockdiv = Clk32 , Data_order = Msb , Ss = Auto
 'SPI on Port E is used
 'portx.7 - SCK
 'portx.6 - MISO
 'portx.5 - MOSI
 'portx.4 - SS

Waitms 1000
Print "Init , set IP to 192.168.1.88"                       ' display a message
Config Tcpip = Noint , Mac = 12.128.12.34.56.78 , Ip = 192.168.1.88 , Submask = 255.255.255.0 , Gateway = 192.168.1.1 , Localport = 1000 , Chip = W5500 , Spi = Spie , Cs = Porte.4
Print "Init Done"


Dim Ip As Long                                              ' IP number of time server
Dim Idx As Byte                                             ' socket number
Dim Lsntp As Long                                           ' long SNTP time
dim bResult as Byte
dim wResult1 as Word, wResult2 as Word

Print "TCP demo"

'Ip = Maketcp(173.194.65.101)                                  'assign IP from google.com or any other IP with a web server that allows a connection

'the next line is used for testing. the line above can be used for a test to a server that responds
Ip=MakeTCP(173.194.65.222)                                     ' use this for a server that does not respond

Print "Connecting to : " ; Ip2str(ip)

'we need to get a TCP socket first
Idx = Getsocket(idx , Sock_stream , 0 , 0)                ' get socket for UDP mode, specify port 5000
Print "Socket " ; Idx

bResult = SOCKETCONNECT(idx, IP, 80,1)                     'use port 80
'Notice the 4-th parameter which is 1. This means that socketconnect does not wait but returns immedeately !
print "Result : " ; bresult
wResult1 = 0

Do
  wResult2 = Socketstat(idx , 0)
  if wResult2<>wResult1 then                               'status changed
     print "STATE : " ; wresult2
     wResult1=wResult2
  end if
Loop
End
 


it shows the the setup for SPI E port.
always start with another simple program to check if the module get an IP and can be addressed.

_________________
Mark
Back to top
View user's profile Visit poster's website
christian_B97

Bascom Member



Joined: 16 Oct 2015
Posts: 2

PostPosted: Wed Dec 02, 2020 10:46 pm    Post subject: Reply with quote

Thank you very much.

I could solve the Problem by using the Solution from this Thread:

https://www.mcselec.com/index2.php?option=com_forum&Itemid=59&page=viewtopic&t=11917

Editing the Libary, using $norampz and setting RAMPZ bevore udpwrite / tcpwrite / Config TCPIP and so on resolved it.

Best regards
Chris
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5921
Location: Holland

blank.gif
PostPosted: Thu Dec 03, 2020 8:36 pm    Post subject: Reply with quote

in fact from the history ;

history = for usage in bootloader, define a constant named _loader_page
history = the value depends on the size of the chip. when you use $Loader=8000 you set the address to the &H10000 word address. if you divide this by &HFFFF (or shift to the right by 16 places) you end up with 1, the page.
history = a general number would be const _loader_page = (_ROMSIZE &HFFFF) -1

I guess i never got feedback about this feature since it is implemented in w5500 only and only documented in the lib.

_________________
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 -> BASCOM-AVR 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