Przy pomocy helpa Bascom'a oraz znalezionych informacji w internecie napisałem taki programik:
- '------------------------------------------------------------------
- ' (c) 1995-2020 MCS
- ' xmega-scanner.bas
- 'purpose : scan all i2c addresses to find slave chips
- 'Micro: Xmega128A1
- '------------------------------------------------------------------
- $regfile = "xm256a3udef.dat" ' the used chip
- $crystal = 32000000 ' frequency used
- $hwstack = 40
- $swstack = 40
- $framesize = 40
- Config Submode = New
- 'first enable the osc of your choice
- Config Osc = Enabled , 32mhzosc = Enabled
- 'configure the systemclock
- Config Sysclock = 32mhz , Prescalea = 1 , Prescalebc = 1_1
- '*******************************************************************************
- '************ CONFIGURATION FOR COM1 UART_C0************************************
- ' ' TX-PORTC.3 RX-PORTC.2 com 2 tcp
- Config Com1 = 115200 , Mode = Asynchroneous , Parity = None , Stopbits = 1 , Databits = 8
- 'Open "COM1:" For Binary As #buart_channel 'no need to open any more
- Config Serialin0 = Buffered , Size = 128 , Bytematch = None 'for COM1
- Config Serialout0 = Buffered , Size = 128
- Open "COM1:" For Binary As #1
- 'Config Input1 = Crlf , Echo = Cr
- 'Echo On
- '
- '*******************************************************************************
- '*********** CONFIGURATION FOR COM2 UART_C1*************************************
- ' ' TX-PORTC.7 RX-PORTC.6 (udp com 1 )
- 'Config Com2 = 115200 , Mode = Asynchroneous , Parity = None , Stopbits = 1 , Databits = 8
- 'Open "COM2:" For Binary As #buart_channel
- 'no need to open any more
- 'Config Serialin1 = Buffered , Size = 128 , Bytematch = None 'for COM2
- 'Config Serialout1 = Buffered , Size = 128
- 'Open "COM2:" For Binary As #1
- ' Config Input2 = Cr , Echo = Cr
- 'Echo On
- '*******************************************************************************
- '************ CONFIGURATION FOR COM3 UART_D0************************************
- ' ' TX-PORTD.3 RX-PORTD.2 wifi
- 'Config Com3 = 115200 , Mode = Asynchroneous , Parity = None , Stopbits = 1 , Databits = 8
- 'Open "COM3:" For Binary As #buart_channel 'no need to open any more
- 'Config Serialin2 = Buffered , Size = 128 , Bytematch = None 'for COM1
- 'Config Serialout2 = Buffered , Size = 128
- 'Open "COM3:" For Binary As #2
- 'Echo On
- '
- '*******************************************************************************
- '************ CONFIGURATION FOR COM4 UART_D1************************************
- ' ' TX-PORTD.3 RX-PORTD.2 wifi
- 'Config Com4 = 115200 , Mode = Asynchroneous , Parity = None , Stopbits = 1 , Databits = 8
- 'Open "COM3:" For Binary As #buart_channel 'no need to open any more
- 'Config Serialin3 = Buffered , Size = 128 , Bytematch = None 'for COM1
- 'Config Serialout3 = Buffered , Size = 128
- 'Open "COM4:" For Binary As #3
- 'Echo On
- '
- '*******************************************************************************
- '************ CONFIGURATION 'COM5 UART_E0 **************************************
- ' ' TX-PORTE.3 ' RX-PORTE.2 debug
- Config Com5 = 115200 , Mode = Asynchroneous , Parity = None , Stopbits = 1 , Databits = 8
- 'Open "COM5:" For Binary As #buart_channel 'channel 4
- Config Serialin4 = Buffered , Size = 128 , Bytematch = None 'for COM4
- Config Serialout4 = Buffered , Size = 128
- Open "COM5:" For Binary As #4
- 'Config Input1 = Crlf , Echo = Cr
- ' Echo on
- '
- '*******************************************************************************
- '************ CONFIGURATION 'COM6 UART_E1 **************************************
- ' ' TX-PORTE.3 ' RX-PORTE.2 Xmega_2_SLAVE
- 'Config Com6 = 115200 , Mode = Asynchroneous , Parity = None , Stopbits = 1 , Databits = 8
- 'Open "COM5:" For Binary As #buart_channel 'channel 4
- 'Config Serialin5 = Buffered , Size = 128 , Bytematch = None 'for COM4
- 'Config Serialout5 = Buffered , Size = 128
- 'Open "COM6:" For Binary As #5
- 'Config Input1 = Crlf , Echo = Cr
- ' Echo on
- '
- '*******************************************************************************
- '************ CONFIGURATION 'COM5 UART_F0 **************************************
- ' ' TX-PORTE.3 ' RX-PORTE.2 dwin
- Config Com7 = 115200 , Mode = Asynchroneous , Parity = None , Stopbits = 1 , Databits = 8
- 'Open "COM5:" For Binary As #buart_channel 'channel 4
- Config Serialin6 = Buffered , Size = 128 , Bytematch = None 'for COM4
- Config Serialout6 = Buffered , Size = 128
- Open "COM7:" For Binary As #6
- 'Config Input1 = Crlf , Echo = Cr
- ' Echo on
- '
- '*******************************************************************************
- '*********************************I2C_HARWARE*****************************
- Config Sda = Porte.0
- Config Scl = Porte.1
- '*******************************************************************************
- Enable Interrupts
- Const Usechannel = 1
- Config Twie = 100000 'CONFIG TWI will ENABLE the TWI master interface
- Open "twie" For Binary As #3
- I2cinit #3
- Dim Twi_start As Byte , J As Byte , B As Byte
- Do
- Print #4 , "Scan start"
- For B = 0 To 254 Step 2 'for all odd addresses
- I2cstart #3 'send start
- I2cwbyte B , #3 'send address
- If Err = 0 Then 'we got an ack
- Print #4 , "Slave at : " ; B
- Print #4 , "HEX : " ; Hex(b)
- Print #4 , "BIN : " ; Bin(b)
- End If
- I2cstop #3 'free bus
- Next
- Print #4 , "End Scan"
- End
- Loop
- End
czy może ktoś wytłumaczyć mi w łopatologiczny sposób ( łopatologiczny ) czego jest to adres na liniach jest tylko na tą chwilę ten jeden DS3231 i jak pobierać dane i zapisywać ustawienia daty, godziny itp.
Może by się czegoś znowu nauczył bo mam coraz więcej bad sektorów w starej głowie .
pozdrawiam Jacek.