How can I generate an I2C Stop condition on ADuC7061?
Have you any source code?
Your source code looks okay.
I do notice that you are writing address 0x02 as the Slave address - is this not a reserved address?
What is your slave?
When you run your code, what do you see on the SCL/SDA pins - do you get a valid Start+addr+ACK?
Can you give us more information?
When the ADuC7060 is in Master mode, the stop condition is generated automatically by the I2C hardware when it detects a NACK bit or, if it knows the previous ACK was for the last byte in a transmission to a particular Slave.
Therefore, if you want to force a Stop condition, you want to end all future byte transfers:
Read cycle: If the current sequence is a read by the Master from a Slave, then setting the I2CMCNT0 register to its minimum value will end the transmission.
Write cycle: When the Master is writing data to a Slave, the Slave actually controls the ACK/NACK. One way of prematurely resetting a write is to disable/reenable the I2C enable bit in I2CMCON or to flush the Tx FIFO and not re-load it.
In this case you don't need to anything after the 4 x data bytes are gone - the Tx FIFO will be empty and the I2C block will know to issue an automatic stop condition if it detects the Tx FIFO is empty during a write sequence.
Just let the hardware control the generation of the Stop condition.
I would suggest you review the example code that came with the Eval-ADuC7061MKZ for more information.
I tested address 0xa0 too.
Olimex LPC-P2103 with NXP LPC2103 is my slave.
No I don't get a valid Start+addr+ACK. I don't get anything. I2C LPC2103 ignore data If address is wrong.
I2C master Rotronic HС2-S3C3 (temperature & humidity sensor) works with my slave good.
I'd like to repeat this sensor protocol only.
What is the current status with this?
You should at least see the Start+Address on the SDA/SCL pins.
If you disconnect the Slave from the ADuC7060, do you see anything on the SDA/SCL pins?
What is the value of POWCON1? - this register can disable the internal clock to the I2C block .
I tested with
POWKEY3 = 0x76; POWCON1 = 0x24; POWKEY4 = 0xB1;
The result is the same. I don't get anything on SCL pin. Maybe ADuC7061 is invalid ?
I am beginning to wonder if we are looking in the right area.
What is working in your application - can you toggle any pin on the chip?
What compiler/debug tools are you using.
If you post your hex file, I can test this here.
Software I2C at GPIO pins p0.1 & p0.3 (software SCL & SDA), ADC, UART work good.
I am using KickStart edition of IAR Embedded Workbench for ARM v.5.4.
My project in attach.
We have opened your project file with IAR and yes, we can see the issue.
However, when we port your c file for Keil, it works correctly!
Using IAR, the I2C control registers are not being written to - even though GP0CON0 is being updated.
We have checked the project settings and they look okay. We can't explain the issue at this time and thus don't have a solution.
This is probably an issue for IAR - we look into it further next week but, we are happy it is not an issue with the ADuC7060.
When using IAR, we configured the programming pod in exactly the same way so, it is not the JTAG pod.
Thank you very much.
I found an error.
GP0KEY2 = 0x13; // early was POWKEY2 = 0x13;
Thanks for your help.
Retrieving data ...