Wgrałem testowy program w bascom na atmega328p :
Code: [Zaznacz cały] [Rozwiń/Zwiń]
- $REGFILE = "M328PDEF.DAT"
- $CRYSTAL = 20000000
- $BAUD = 115200
- $HWSTACK = 100
- $SWSTACK = 100
- $FRAMESIZE = 100
- ENABLE INTERRUPTS
- '*******************************************************************************************************************************************************
- '*** UART-COM1 *****************************************************************************************************************************************
- '*******************************************************************************************************************************************************
- CONFIG COM1 = 115200 , SYNCHRONE = 0 , PARITY = NONE , STOPBITS = 1 , DATABITS = 8 , CLOCKPOL = 0
- OPEN "COM1:" FOR BINARY AS #1
- CONFIG SERIALIN0 = BUFFERED , SIZE = 10 , BYTEMATCH = 13
- DIM RS232_1 AS STRING*11
- DIM COM1 AS LONG
- ENABLE URXC
- '*******************************************************************************************************************************************************
- '*** SPI ***********************************************************************************************************************************************
- '*******************************************************************************************************************************************************
- Config Spi = Hard , Interrupt = Off , Data_order = Msb , Master = Yes , Polarity = Low , Phase = 0 , Clockrate = 4 , Noss = 0
- 'Init the spi pins
- Spiinit
- '*******************************************************************************************************************************************************
- '*** ZMIENNE *******************************************************************************************************************************************
- '*******************************************************************************************************************************************************
- CONFIG PORTD.2 = OUTPUT
- PORTD.2=0
- WAIT 1
- PORTD.2=1
- '*******************************************************************************************************************************************************
- '*** PORT / PIN ****************************************************************************************************************************************
- '*******************************************************************************************************************************************************
- '*******************************************************************************************************************************************************
- '*** PROGRAM *******************************************************************************************************************************************
- '*******************************************************************************************************************************************************
- Const Epr = 0
- Config Tcpip = NOINT , Mac = 12.128.12.34.56.78 , Ip = 192.168.1.10 , Submask = 255.255.255.0 , Gateway = 192.168.1.2 , Localport = 1000 , Tx = $55 , Rx = $55 , Chip = W5100 , Spi = 1
- Print #1 ,"Init Done"
- 'The next code is optional. It shows how to change the IP at run time
- #if Epr = 1
- Dim Xx As Eram Long ' this is 4 bytes of EEPROM
- Dim Zz As Long ' this is a long
- Zz = Xx ' read eeprom
- Dim B4 As Byte
- B4 = 8
- 'use maketcp to create an IP number
- 'notice that last param is a variable.
- 'all bytes could be variables of course
- Zz = Maketcp(192 , 168 , 0 , B4)
- 'in reverse order
- Zz = Maketcp(b4 , 9 , 168 , 192 , 1)
- 'simplest form
- Zz = Maketcp(192.168.0.8)
- Print Ip2str(zz)
- Settcp 12.128.12.34.56.78 , Zz , 255.255.255.0 , 0.0.0.0
- ' ^ notice the variable that holds the IP address 192.168.0.8
- ' from the EEPROM data line below
- #endif
- DO
- LOOP
- END
- '-------------------------------------------------------------------------------------------------------------------------------------------------------
- SERIAL0CHARMATCH:
- PUSHALL
- INPUT #1 , RS232_1 NOECHO
- COM1 = VAL(RS232_1)
- POPALL
- RETURN
- $eeprom
- ' take care, data is stored byte, by byte so reversed notation is used
- Data 8 , 0 , 168 , 192 ' this is 192 , 168 , 0 , 8
- $data
Stety i niestety ale nie znam się na robieniu stron , serverów itp by można było sterować atmegą lub pobierać dane z czujnika i wyświetlać na stronie w net. Mam jednak pytanie czy jest możliwe użyć tych modułów do transmisji danych między dwiema atmegami ? coś w stylu rs232 tyle że po kablu sieciowym na duże odległości .
Są przykłądy w Bascom ale nie wiem za któy się zabrać .