View previous topic :: View next topic |
Author |
Message |
bvlaar
Joined: 10 Oct 2010 Posts: 4
|
Posted: Mon Feb 03, 2014 12:28 pm Post subject: I2C Problem with ATMega 168pa |
|
|
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 |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5921 Location: Holland
|
Posted: Mon Feb 03, 2014 12:38 pm Post subject: |
|
|
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 |
|
|
bvlaar
Joined: 10 Oct 2010 Posts: 4
|
Posted: Mon Feb 03, 2014 1:34 pm Post subject: |
|
|
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 |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5921 Location: Holland
|
Posted: Mon Feb 03, 2014 1:44 pm Post subject: |
|
|
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 |
|
|
bvlaar
Joined: 10 Oct 2010 Posts: 4
|
Posted: Tue Feb 04, 2014 3:07 am Post subject: |
|
|
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 |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5921 Location: Holland
|
Posted: Tue Feb 04, 2014 8:42 am Post subject: |
|
|
maybe studio 5 programmer did not work?
I have no idea. maybe a wire or setting in studio options? _________________ Mark |
|
Back to top |
|
|
bvlaar
Joined: 10 Oct 2010 Posts: 4
|
Posted: Wed Feb 05, 2014 2:44 am Post subject: |
|
|
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 |
|
|
|