Most ever online: 170
Guests: 170,
Members: 0
on Sunday 15 January 2023 - 07:39:26
Chatbox
You must be logged in to post comments on this site - please either log in from the Login box or from here.If you are not registered click here to signup.
It is nomather if it is faster. When you lock AVR with UPDI you need a 12V pulse to unlock it. I think even SNAP cant do that.
On the shop site there is a link to oryginal design for this tool. 12V pulse is controlled by RTS signal. It must be low to drive PNP transistor. Bascom can handle both DTR and RTS signals but only DTR can be inverted. I dont know on which state is RTS signal "normally". Maybe there is a permanent low state and this tool inject 12V over that PNP transistor so communication cannot be established.
you need to merge the samples. i did not test it with hardware but the SLAVE will work on the first TWi (twi0). This means the master need to use TWI1. (unless you modify the lib to of the add on)
'in this demo we only use the second SPI interface Config Spi1 = Hard , Interrupt = Off , Data_order = Msb , Master = Yes , Polarity = Low , Phase = 0 , Clockrate = 128
'some constants for the signature row Const Device_signature_byte1 = 0 Const Device_signature_byte2 = 2 Const Device_signature_byte3 = 4
$lib "I2C_TWI-MULTI.lib" 'important for using 2 TWI interfaces
Dim _i2cchannel As Byte ' you MUST dim this variable yourself when using the above lib Dim B As Byte 'just a used byte Dim A(10) As Byte
I2cinit 'default TWI init I2cinit Twi1 'optional specify TWI1 to init that interface
Open "com2:" For Binary As #2 'create a channel to reference the UART
'print the chip ID Print "ID : " ; Hex(readsig(device_signature_byte1)) ; Hex(readsig(device_signature_byte2)) ; Hex(readsig(device_signature_byte3))
'all I2C statements will work the same. All you need to do is to set the _i2cchannel variable to 0 or 1 _i2cchannel = 1 'try the second bus
Print "Scan start" For B = 0 To 254 Step 2 'for all odd addresses I2cstart I2cwbyte B 'send address If Err = 0 Then 'we got an ack Print "Slave at : " ; B ; " hex : " ; Hex(b) ; " bin : " ; Bin(b) End If I2cstop 'free bus Next
'second SPI Spi1init B = 5 Spi1out A(1) , B Spi1in A(1) , B A(1) = Spi1move(a(2))
Do Print "COM1" Print #2 , "COM2" Waitms 1000 Loop
'The following labels are called from the library. You need to insert code in these subroutines 'Notice that the PRINT commands are remarked. 'You can unmark them and see what happens, but it will result in occasional errors in the transmission 'The idea is that you write your code in the called labels. And this code must execute in as little time 'as possible. So when you slave must read the A/D converter, you can best do it in the main program 'then the data is available when the master needs it, and you do not need to do the conversion which cost time.
'A master can send or receive bytes. 'A master protocol can also send some bytes, then receive some bytes 'The master and slave must match. 'the following labels are called from the library when master send stop or start Twi_stop_rstart_received: ' Print "Master sent stop or repeated start" Return 'master sent our slave address and will not send data Twi_addressed_goread: ' Print "We were addressed and master will send data" Return
Twi_addressed_gowrite: ' Print "We were addressed and master will read data" Return 'this label is called when the master sends data and the slave has received the byte 'the variable TWI holds the received value Twi_gotdata: 'Print "received : " ; Twi ; " byte no : " ; Twi_btw Select Case Twi_btw Case 1 : Portb = Twi ' first byte Case 2: 'you can set another port here for example End Select ' the setting of portb has nothing to do with the ADC Return 'this label is called when the master receives data and needs a byte 'the variable twi_btr is a byte variable that holds the index of the needed byte 'so when sending multiple bytes from an array, twi_btr can be used for the index Twi_master_needs_byte: 'Print "Master needs byte : " ; Twi_btr Select Case Twi_btr Case 1: ' first byte W = Getadc(0) 'in this example the conversion is done here ' but a better option would have been to just pass the value of W and do the conversion in the main loop 'Print "ADC-SLAVE:" ; W Twi = Low(w) Case 2 ' send second byte Twi = High(w) End Select Return
'when the mast has all bytes received this label will be called Twi_master_need_nomore_byte: ' Print "Master does not need anymore bytes" Return [/code:1:a920eb11dc]
the samples uses adc but it is not configured as i just copy some twi slave code. but the important thing : twi0 will be used as slave and twi1 as master.
Do you have I2C-Slave library? "I2C TWI Slave is part of the I2C-Slave library. This is an add-on library that is not included in Bascom-AVR by default." [url=https://avrhelp.mcselec.com/config_twislave.htm?zoom_highlightsub=twi%2Bslave]TWI Slave - HELP
[quote:7ee783da33="andrge"]I did not find anything about 328pb with master and slave in the demo from bascom.[/quote:7ee783da33] Because Bascom without add-on supports TWI-Master only.
Do you have I2C-Slave library? "I2C TWI Slave is part of the I2C-Slave library. This is an add-on library that is not included in Bascom-AVR by default." [url=https://avrhelp.mcselec.com/config_twislave.htm?zoom_highlightsub=twi%2Bslave]TWI Slave - HELP
i have a question about the twi and atmega328pb. for my project i would like to use the twi0 as slave and the twi1 as master. How can I configure the twi slave?
I did not find anything about 328pb with master and slave in the demo from bascom. Can someone give me a tip or an example?
I found an example for the 328pb in my MCS folder under smaples/chips. However, no slave is used here. It is the dame demo as on the help side, here https://avrhelp.mcselec.com/index.html?i2c_twi_multi.htm
regards Andreas
[b:8aa0c4508d][color=red:8aa0c4508d](BASCOM-AVR version : 2.0.8.6 , Latest : 2.0.8.6 )[/b:8aa0c4508d][/color:8aa0c4508d]
BASCOM-AVR : UPDI : REPLY
Above Mark asked about the SNAP V1 and V2 VIDs.
I have both SNAP versions.
The new SNAP V2 has a small 3-Pin header on the SNA...
»
BASCOM-AVR : UPDI : REPLY
[quote:14703ece8d="programmista123"]Hi,
Could you share programmer options screenshot?
Do you have any errors?[/quote:14703ece...
»
BASCOM-AVR : UPDI : REPLY
It is nomather if it is faster.
When you lock AVR with UPDI you need a 12V pulse to unlock it.
I think even SNAP cant do that....
24 Volt wie verteilen? Hallo, ich möchte gerne vom Keller bis zum Dachboden 24V durchleiten. Als Kabel liegt schon 15m sowas wie NYM Kabel und 20 m BK KOAX Kabel. Die St...
»
Quellcode aus Hex oder Bin erzeugen Hallo
Ich habe ein Programm für den Atmega 8515 das mir
im Hex Format vorliegt. Kann man daraus wieder Quellcode erzeugen.
Das ganze diente als Ste...
»
Servo über Timer2 Ein frohes Neues,
einen Servo mit einem 8bit Timer zu steuern ergibt recht wenig Stufen, wenn die 20ms Wiederholrate (annähernd) eingehalten wird.
...
»
Guten Rutsch und ein gutes neues Jahr Jungs Hi, bin nicht wirklich aktiv hier und selten bis gar nicht wirklich eine Hilfe. Ändert nichts daran dass genau dieses Forum mir sehr viel bedeutet....
»
UPDI-Programmierung Abendgruß aus MD,
will mir die neuen ATTiny412 u. 414 zulegen und diese mit UPDI programmieren.
In BASCOM werden diese ja unter ATxtiny412 aufgefü...
R.I.P Ben Zijlstra
Remembering Ben Zijlstra
We hope that people who love Ben will remember and celebrate his life.
more info at MCS
www.mcselec.com/index2.ph...
»
KaRadio webradio ESP8266
The Dimitris board is available at https://github.com/dsaltas/WiFi-WebRadio
This is a hardware project for Ka-Radio
»
93C46 small tool to edit 93C46 eeprom written in BascomAVR & VB
Bascom control the 93C46 so we sent data via comport from VB
code will be added later ...
»
nRF24L01+ RC Controller This is a RC controller TX & RX unit with nRF24L01+
nRF24L01+ / with PA and LNA for longer range
facts:
TX
1 x potmeter for servo
...
»
RAW lcd Connecting RAW lcd to atmega8
the lcd is 6 digit + time glass
LCD Hour Meter for tractor ,air compressor, ect
the lcd have 4 com pins & 14...