Cannot set TWI clock under 30khz

General discussion on mikroBasic PRO for AVR.
Post Reply
Author
Message
legianrd
Posts: 8
Joined: 14 Aug 2018 13:40

Cannot set TWI clock under 30khz

#1 Post by legianrd » 14 Aug 2018 13:54

Hi, I need to establish TWI communication under 5khz, but when I set values under 30khz in TWI_Init() routine the real clock I can read with logic analyzer is around 100kHz. Setting values over 30khz to 400khz the clock readed is the same I set.

I'm using Atmega32 with 16Mhz xtal. I need some help.

Please, can anyone help me?

legianrd
Posts: 8
Joined: 14 Aug 2018 13:40

Re: Cannot set TWI clock under 30khz

#2 Post by legianrd » 23 Aug 2018 19:36

Solved.

Instead of using TWI_Init() function I've used the following equation from Atmega32 datasheet

SCLclock = CPU_FREQ/16+ 2(TWBR)*4^TWPS

So, setting registers value as TWBR=0x72 and TWSR=0xFB I've got a 1095Hz SCL clock.

Post Reply

Return to “mikroBasic PRO for AVR General”