Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

I2C Problem with ATMega 168pa

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive
View previous topic :: View next topic  
Author Message
bvlaar

Bascom Member



Joined: 10 Oct 2010
Posts: 4

PostPosted: Mon Feb 03, 2014 12:28 pm    Post subject: I2C Problem with ATMega 168pa Reply with quote

Dear all,
I try to drive a MIDAS-Display (ST7032 Controller) with a ATMega 168pa. I have also two port expander and some other I2C connected with the bus.
After a long sequence of trying to initialize the display I got doubts whether the TWI is working. I also tested both expander and also no reaction.
The pull up resistors are connected 3,3V -> 4k7.

By reading the documentation from Atmel for ATMega168 I found this remark:

Quote:
The PRTWI bit in ”Power Reduction Register - PRR” on page 40 must be written to zero to
enable the 2-wire Serial Interface.


PRTWI is bit 7

In m168pdef.dat I found PRR=$64. Is it comparable with &H64? Is it possible to change to &H24 ($24, in this case bit 7 would be 0)? Is it the reason why TWI canīt be accessed?

best regards,
Benedikt

(BASCOM-AVR version : 2.0.7.6 , Latest : 2.0.7.7 )
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5921
Location: Holland

blank.gif
PostPosted: Mon Feb 03, 2014 12:38 pm    Post subject: Reply with quote

the register is 0 by default/reset so TWI is enabled.

do you use TWI mode (lib included???) or soft mode twi?
Better to show some code!

_________________
Mark
Back to top
View user's profile Visit poster's website
bvlaar

Bascom Member



Joined: 10 Oct 2010
Posts: 4

PostPosted: Mon Feb 03, 2014 1:34 pm    Post subject: Reply with quote

Here is one sample. The base of this sample is from one post. I modified a little bit.

So that I failed to initialize the Display, I tried to access a PCA9554 expander. I also failed and then I found the remark in the documentation from Atmel regarding the PRR and PRTWI-Bit.

How can I check the value of the Power-Reduction-Register?
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5921
Location: Holland

blank.gif
PostPosted: Mon Feb 03, 2014 1:44 pm    Post subject: Reply with quote

you can simply print the value just like any other register.

i advise to first run the i2cscanner from the samples . it will show all i2c devices on the bus.

_________________
Mark
Back to top
View user's profile Visit poster's website
bvlaar

Bascom Member



Joined: 10 Oct 2010
Posts: 4

PostPosted: Tue Feb 04, 2014 3:07 am    Post subject: Reply with quote

Dear Mark,
thanks for information. The program is now working. The last days I used AVRStudio 5 with the known results. Finally I tried the same code without any changings with AVRStudio 6 and the display started. Any idea about the reason why I2C didnīt work?

Much thanks again.
Best regards,
Benedikt
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5921
Location: Holland

blank.gif
PostPosted: Tue Feb 04, 2014 8:42 am    Post subject: Reply with quote

maybe studio 5 programmer did not work?
I have no idea. maybe a wire or setting in studio options?

_________________
Mark
Back to top
View user's profile Visit poster's website
bvlaar

Bascom Member



Joined: 10 Oct 2010
Posts: 4

PostPosted: Wed Feb 05, 2014 2:44 am    Post subject: Reply with quote

Hi Mark,
I think Iīm coming closer to the reason of my problem. Sometimes the display is working. Itīs not a problem of AVRStudio or Bascom. Itīs a selfproduced problem. It seems that there could be a problem with ground on the board.
So the bus is sometimes active and sometimes breaking down.

thanks
Benedikt
Back to top
View user's profile
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive All times are GMT + 1 Hour
Page 1 of 1

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