Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Initalization of I2C AXTINY3217

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR XTINY/MEGAX/AVRX
View previous topic :: View next topic  
Author Message
kasny.ondrej

Bascom Member



Joined: 03 Feb 2024
Posts: 61

czechrepublic.gif
PostPosted: Mon Aug 04, 2025 10:24 am    Post subject: Initalization of I2C AXTINY3217 Reply with quote

Hello Mark,
I work with Atxtiny3217 on some project. I use I2c bus for some communication. When code get past I2cinit TWI0, it also enables internal pullups on alternate pins (PA1, PA2) which is undemanded becouse of other connections. I will rewrite it in PORT register back but is it intended behavour?

Code:


$regfile = "atxtiny3217.dat"
Config Submode = New
Config Base = 0
$crystal = 20000000
$hwstack = 80
$swstack = 48
$framesize = 150

'$sim
'$dbg
Config Sysclock = 16_20mhz , Prescale = 1

Const _valcheck = 1
Const Updateeprom = 1



Config Com1 = 115200 , Mode = Asynchroneous , Parity = None , Databits = 8 , Stopbits = 1 , Baud_offset = Osc20_5v
Config Serialin = Buffered , Size = 60
Config Serialout = Buffered , Size = 100

Config Twi0 = 100000
Config I2cdelay = 100
I2cinit Twi0
Dim Twi_start As Byte                                      

Porta_pin1ctrl = 0 ' need to reassign register bits
Porta_pin2ctrl = 0

'-------------------------------ADC CONFIG---------------------------------
Config Vref = Dummy , Adc0 = 4v3 , Adc1 = 1v1
Config Adc0 = Single , Resolution = 10bit , Adc = Enabled , Reference = Internal , Prescaler = 32 , Sample_cap = Above_1v , Init_delay = 32 , Sample_accu = 4 , Mux = Ain1

Vtg_monitor Alias Porta.1 : Config Porta.1 = Input


Dim Adc_get As Word

Enable Interrupts

Do
Adc_get = Getadc()
Print Adc_get

Wait 1
Loop
[/code]
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 6233
Location: Holland

blank.gif
PostPosted: Mon Aug 04, 2025 10:45 am    Post subject: Reply with quote

This is caused by i2cinit which will do a pullup on scl/sda
But for this processor it uses the wrong pins.
You do not need to call i2cinit when you do not need internal pull up. That is : for xtiny platform.
I will change it so the proper default pins will be used

_________________
Mark
Back to top
View user's profile Visit poster's website
kasny.ondrej

Bascom Member



Joined: 03 Feb 2024
Posts: 61

czechrepublic.gif
PostPosted: Mon Aug 04, 2025 10:52 am    Post subject: Reply with quote

OK, thank you for explaination.
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR XTINY/MEGAX/AVRX All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can 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