Quantcast
Channel: MCS Electronics Forum
Viewing all articles
Browse latest Browse all 20563

EASY TCP/IP : Arduino Ethernet shield not working with atMega1280 ? Modbus : NEWTOPIC

$
0
0
Hi! I write ModbusTCP server protocol using Arduino uno R3 and cheap 10$ Ethernet shield with W5100. It work GREAT! Fast response to Twincat PLC too. This is setup, nothing fancy, I just copied from some TCP example file: [code:1:05367bb6c3]$projecttime = 64 '$regfile = "m32def.dat" ' chip used '$regfile = "m16def.dat" ' chip used $regfile = "m328pdef.dat" '$regfile = "m1280def.dat" $hwstack = 128 $swstack = 128 $framesize = 64 ' For different boards '$Crystal = 8000000 '$Crystal = 11059200 '$Crystal = 12288000 '$Crystal = 14745600 $Crystal = 16000000 ' ARDUINO UNO R3 '$Crystal = 18432000 ' MY Board with AtMega1280 '$Crystal = 22118400 Debug off '**************************************************************** ' MCU hardware configuration '**************************************************************** Config Spi = Hard , Interrupt = Off , Data Order = Msb , Master = Yes , Polarity = Low , Phase = 0 , Clockrate = 4 , Noss = 0 'Init the spi pins Spiinit 'Enable Interrupts ' before we use config tcpip , we need to enable the interrupts Config Tcpip = NOINT , Mac = 00.128.12.34.56.79 , Ip = 192.168.40.70 , Submask = 255.255.255.0 , Gateway = 192.168.40.1 , Localport = 502 , Tx = $55 , Rx = $55 , Chip = W5100 , Spi = 1[/code:1:05367bb6c3] Then I move "program" to bigger board and bigger CPU, and change setup as folow: [code:1:05367bb6c3]$projecttime = 69 '$regfile = "m32def.dat" ' chip used '$regfile = "m16def.dat" ' chip used '$regfile = "m328pdef.dat" $regfile = "m1280def.dat" $hwstack = 128 ' 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 ' For differnt boards '$Crystal = 8000000 '$Crystal = 11059200 '$Crystal = 12288000 '$Crystal = 14745600 '$Crystal = 16000000 ' ARDUINO UNO R3 $Crystal = 18432000 ' MY Board with AtMega1280 '$Crystal = 22118400 Debug off '**************************************************************** ' MCU hardware configuration '**************************************************************** Config Spi = Hard , Interrupt = Off , Data Order = Msb , Master = Yes , Polarity = Low , Phase = 0 , Clockrate = 4 , Noss = 0 'Init the spi pins Spiinit Config Tcpip = NOINT , Mac = 00.128.12.34.56.79 , Ip = 192.168.40.70 , Submask = 255.255.255.0 , Gateway = 192.168.40.1 , Localport = 502 , Tx = $55 , Rx = $55 , Chip = W5100 , Spi = 1[/code:1:05367bb6c3] So I changed only CPU definition and clock. Someone my notice I dint use interrupts, but it workin nicely without. And... Program not working. No PING response from W5100. I had chacked my hardware VERY carefully at leat 5 times. Logic probe on SS pin show low lewel after restart. This is connection to Ethernet Shield from my board: +5V and GND atMega1280 pins 19,20,21,22 (ss, mosi, miso, sck) to ethernet shields pins 10,11,12,13. I didn't connected Reset pin since ethernet shiald boards has its own reset circuit. Also have to say that I use UTP and RJ54 connection from atMEga1280 board to ethernet shield, 50cm long. I have tryed to change clock rate, but not phase and polarity, since I presume it should work with that parameters, since I have no problem with Arduino board. Even tryed tu use interrpts as in sample, but nothig help. When returning shield to Ard. UNO it work again. Only have option to reduse SPI cable to 10cm, but I thinq this would not solve problem. And maybe try on arduino Mega, but I don't have with me right now. Any idea why same program and same hardware connection not wrking on atMEga1280 ?

Viewing all articles
Browse latest Browse all 20563

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>