View previous topic :: View next topic |
Author |
Message |
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Sat Jan 07, 2023 10:48 am Post subject: Re: Pin assignments |
|
|
AlanGHosler wrote: | I don't share the pins. I use d.2 for sda, d.4 for scl and c.4 for ILI9341 *RS
I did that because in Help under "Config I2Islave" it states that for the ATmega168 scl is d.4 and sda is d.2. I assume this is so because d.2 is also INT0 so it will see the first data bit as an interrupt.
I have put back in the code the following
Config sda = portd.2
Config scl = portd.4 |
you original used a different processor/slave lib.
but now you use the one that supports TWI.
From the help :
i2c_TWI-slave.LBX : This library can be used when an AVR have an TWI/I2C hardware interface like for example ATMEGA8, ATMEGA644P or ATMEGA128. In this case the hardware SDA and SCL pin's of the AVR will be used (with ATMEGA8: SCL is PORTC.5 and SDA is PORTC.4). This library will be used when USERACK = OFF. When USERACK =ON then i2c_TWI-slave-acknack.LBX will be used. See also Config TWISLAVE
So you are not free to chose the pins with this lib, you must use the TWI hardware which is on the pins i mentioned earlier.
now i also read your new comment where you talk about masters on the bus. i really have no time to pull all info out. so that is where i leave it.
i just end with mentioning that that slave lib for TWI is intended to use the TWI hardware. This also means you can not use these pins as a hardware TWI master (not at the same time anyway)
if you need to do master i2c, then i advise to use the soft i2c (the default) for that.
And to be clear : THERE IS NO CONFLICT in the lib. it will work out fine with my earlier comment. _________________ Mark |
|
Back to top |
|
|
O-Family
Joined: 23 May 2010 Posts: 320 Location: Japan
|
Posted: Sun Jan 08, 2023 1:47 am Post subject: |
|
|
Hi,
The environment is ready for testing.
Compiling and writing the [Tank Monitor ColorLCD 12_4_22 forum test.bas] you posted did not cause the trouble you mentioned.
Please provide the program and circuit diagram that is definitely causing the trouble. |
|
Back to top |
|
|
AlanGHosler
Joined: 25 Jan 2011 Posts: 109
|
Posted: Sun Jan 08, 2023 3:08 am Post subject: Test Program |
|
|
Note in the attached test program I use:
SDA D.2
SCL D.4 because I thought that what "Config I2SLAVE" in Help menu indicated I should use for an ATmega168. However, Mark said I needed to stay with
SDA C.4
SCL C.5
I made that change in my program but no success. I did not change my printed circuit board but I can do that with a small effort.
I don't make schematic diagrams anymore. I go right to designing the printed circuit board. I can send that to you. You would need to download the software which is free.
Thanks for your help. |
|
Back to top |
|
|
O-Family
Joined: 23 May 2010 Posts: 320 Location: Japan
|
Posted: Sun Jan 08, 2023 4:36 am Post subject: |
|
|
The program above displays fine here.
It seems that there is some other circuit problem.
If you use TWI, change the [RESET] pin port of the ILI9341 to another port. |
|
Back to top |
|
|
AlanGHosler
Joined: 25 Jan 2011 Posts: 109
|
Posted: Sun Jan 08, 2023 5:30 am Post subject: two questions |
|
|
Do you now have the MCS I2C slave library? If not, how did you get it to compile/
What ports did you use for SDA and SCL? |
|
Back to top |
|
|
O-Family
Joined: 23 May 2010 Posts: 320 Location: Japan
|
Posted: Sun Jan 08, 2023 9:40 am Post subject: |
|
|
I got the I2C slave library and compiled the last program you posted.
The wiring of the circuit is also adapted to your program.
Is the last program you posted the one that causes the anomaly?
If the screen remains white, there is a possibility that the hardware RESET has not been applied at power on.
If you change the [RESET] pin port or do not connect [RESET] to the port, attach a power-on reset circuit with a CR and a diode to the [RESET] pin of the ILI9341. |
|
Back to top |
|
|
AlanGHosler
Joined: 25 Jan 2011 Posts: 109
|
Posted: Mon Jan 09, 2023 12:28 am Post subject: Ports |
|
|
I have the RS wired to the Atmega.
My circuit is
SDA to PD2
SCL to PD4
CS to PD3
RS to PC4
DC to PD5
SDI to PD6
SCK to PD7
I notice that my screen clears as it should in response to Cls. It is after that it goes back to all white.
I have a spare display and ATmega so I am going to bread board a new system like you have. I notice you don't use any level shifting. Can the display take 5v inputs?
Thanks for the effort you have put in on this. |
|
Back to top |
|
|
O-Family
Joined: 23 May 2010 Posts: 320 Location: Japan
|
Posted: Mon Jan 09, 2023 1:42 am Post subject: |
|
|
It took me a while to find the cause as reports of your symptoms have changed.
In that case, since the [RESET] pin of PC4 overlaps with TWI, it seems that the ILI9341 is initialized and the hardware RESRT is applied to the ILI9341 again by the startup of TWI, and the screen turns white.
I repeat my statement, the [RESET] pin should be disconnected from TWI and changed to another port.
A 5V power supply is possible if your module has a 3.3V regulator on the back of the board.
However, since the interface pins are directly connected to the ILI9341, all of them are up to 3.3V, so a level shift is required. |
|
Back to top |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
Posted: Mon Jan 09, 2023 11:13 am Post subject: |
|
|
O-Family wrote: | In that case, since the [RESET] pin of PC4 overlaps with TWI, ...
I repeat my statement, the [RESET] pin should be disconnected from TWI and changed to another port. |
You repeat only Mark's statement, who wrote already 10 posts and nearly 2 days ago:
albertsm wrote: | pay attention to RST which is on port C.4
now you also use the TWI slave which uses TWI hardware which is on pins C.5 (scl) and C.4(sda)
so now you get it : the sda is shared with the reset.
so the solution is to rewrite rst to some other port |
I think it's fair to give credit to whom credit is due. |
|
Back to top |
|
|
|