View previous topic :: View next topic |
Author |
Message |
tonkostz
Joined: 07 May 2011 Posts: 56 Location: Bulgaria
|
|
Posted: Sat Dec 28, 2024 4:42 am |
|
|
Thanks!
I am still not sure how the I2C scanner code works. After finishing i show address: EE and 112 devices found. I watch this on a LCD and not from the serial port as in the original code. Please, give me a clue what is wrong here. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19649
|
|
Posted: Sat Dec 28, 2024 5:28 am |
|
|
The reason I2C is not mentioned, is that this was a registered name, when
this chip was being done, and the manufacturers elected not to license
the term. TWI (Two wire interface), is a term that Quintic used to avoid
having to license using the name. The registration actually expired in 2011,
but some manufacturers just don't want to use the term....
Now 112 devices found implies the lines are not correctly going up.
How long are the wires?. Though 3.3K should work for a single device
with short wires, I suggest going quite a bit lower. Also specify the speed
on the I2C setup. SLOW=100000. How is the device connected?. Is this
all on a single board, or are you using an attached board with the chip?.
If the latter, look very carefully at how good these connections are and how
we'll smoothed the power rails actually are. |
|
|
tonkostz
Joined: 07 May 2011 Posts: 56 Location: Bulgaria
|
|
Posted: Sat Dec 28, 2024 5:59 am |
|
|
The chip is on the main board and i use a separate small board with the mcu attached to the main board. It is a single device and the wires are about 3cm long between the mcu and the chip.
Here is a picture of the whole thing with the original control board on the photo:
As soon as insert the original control board with STC mcu everything works and chip responds to commands. One more thing. On thhe original board there are no pull-up resistors on both SDA and SCL? Maybe they are using internal pull-ups in the mcu? Also the STC mcu is powered from +4V and there are 100 ohms series resistors on both SDA and SCL to the chip. QN8007 is powered from +3.3V.
I have made the following test to see what is happening.
When i disconnect both SDA and SCL from the slave chip but leave the pull-up resistors connected to the mcu. When i power on, it immediately says "Nothing found".
When SDA and SCL are connected to the chip, count is incremented at each address and in the end the number is equal to the addresses which are tried.
So the chip responds to each address or something wrong with the wiring maybe? |
|
|
tonkostz
Joined: 07 May 2011 Posts: 56 Location: Bulgaria
|
|
Posted: Sun Dec 29, 2024 2:57 am |
|
|
Here are some oscillograms from different addresses while the I2C scanner program is running. Pull-up resistors are now 2K4 to +3.3V. It seems like the chip is responding to each address or i am wrong? Blue trace is SCK and the read trace is SDA.
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19649
|
|
Posted: Sun Dec 29, 2024 4:03 am |
|
|
OK. I suspect the scanner will not work with this.
As explained earlier, this was a bus where the sellers didn't want to pay
any licensing to use I2C. I have played with it in the past, and know
that you can use I2C drivers to talk to it OK, _But_, the bus uses active
pull up/down on the master, not open collector drives, so does not send
an ACK back from the slave. Effectively it is 'one way' I2C, with no
clock stretching, or ACK. I drove it using a software I2C, and could talk
to the chip, but doubt if the hardware will work, because the master will
not get the ACK correctly.
So, forget the bus scanner. Set your I2C configuration to FORCE_SW, and
just try sending value to the chip. I suspect you will then find it works. |
|
|
Al in Michigan
Joined: 29 Dec 2024 Posts: 13 Location: michigan
|
me too |
Posted: Sun Dec 29, 2024 6:20 pm |
|
|
I'm having the same problem with this chip (QN8007). This is my second go around. I first ordered the IC thru aliExpress and when they (tried 2 of 5) didn't work I suspected counterfeits so I ordered fro another Chinese dealer (the only sources I can find are Chinese). These also do not work as expected -- running simple github code. Also cannot get it to respond to an I2C ID. I found this thread SEARCHING for a way to proceed. I'll monitor & contribute if I find anything. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19649
|
|
Posted: Mon Dec 30, 2024 1:23 am |
|
|
That makes a lot of sense.
Thing to understand is these are obsolete chips. Over fifteen years old.
Suspect genuine sources may well have pretty much dried up, so the
supplies are largely fake.
Would explain a lot.... |
|
|
Al in Michigan
Joined: 29 Dec 2024 Posts: 13 Location: michigan
|
|
Posted: Mon Dec 30, 2024 10:07 am |
|
|
Fake devices is what I'm thinking. Usually just a simple access to any chip is not too hard, normally straight forward. I've got several hour into this with zero progress. OTOH I'm in contact with a guy in Germany who recently bought some of these from China and they're working fine. I'm pretty close to cutting bait on this. |
|
|
tonkostz
Joined: 07 May 2011 Posts: 56 Location: Bulgaria
|
|
Posted: Tue Dec 31, 2024 9:27 am |
|
|
I have finally made it work. It was very simple - just sending data to the chip and it works. Thanks to Ttelmah and all other trying to help.
I've lost too many time thinking it was a standard I2C bus and finding out why the I2C scanner was not working.
Finally, i have to mention that i had oringinal control board with differemt mcu and i was sure that the chip is working and not fake.
If anybody needs help controlling this chip, please contact me. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19649
|
|
Posted: Tue Dec 31, 2024 11:38 am |
|
|
Good, That was why I suggested this.
It is not I2C, just happens to be drivable as I2C, but lacks the responses
on the clock line giving ACK, which is why the scanner won't work. |
|
|
Al in Michigan
Joined: 29 Dec 2024 Posts: 13 Location: michigan
|
|
Posted: Wed Jan 01, 2025 10:18 am |
|
|
Well mine's still not working & I could use some help. Can you offer suggestions or post a snippet of code that I can use to make contact with the chip ? |
|
|
tonkostz
Joined: 07 May 2011 Posts: 56 Location: Bulgaria
|
|
Posted: Thu Jan 02, 2025 2:23 am |
|
|
This is my code kust to initiate the chip and make it transmit at a desired frequency (107.30MHz in my case). Note that the frequency is written in two registers: CH (lower 8 bits of the 10 btin channel index) and the highest 2 bits in CH_STEP. In my case 107.30MHz channel index is 0x272 so i write 0x72 in register CH and 0x02 in register CH_STEP.
Code: | #include <18F4550.h>
#device adc=10
#fuses HSPLL,PLL5,CPUDIV1,NOWDT,MCLR,PUT,NOLVP,USBDIV,VREGEN,BROWNOUT,NOPROTECT,NOCPB,NOCPD
#use delay(clock=48000000)
#use i2c(master,FORCE_SW,slow,sda=PIN_D7,scl=PIN_D5,smbus) // Configure Device as Master
#include <qn8007.h>
int buffer;
int8 tstep;
int16 freq=1073; //this is frequency in MHz*10
////////////////////////WRITE/////////////////////////////
void qn8007_write(int Reg, int val)
{
i2c_start();
i2c_write(0x56); //QN8007_ADDR_WRITE
i2c_write(Reg); //register name/address
i2c_write(val); //data to be written
i2c_stop();
}
////////////////////////READ/////////////////////////////
int qn8007_read(int Reg)
{
//unsigned int data = 0;
//int buffer;
i2c_start();
i2c_write(0x56); //QN8007_ADDR_WRITE
i2c_write(Reg); //register name/address
i2c_start(); //restart
i2c_write(0x57); //QN8007_ADDR_READ
buffer = i2c_read(0); // read and store the data in a variable
i2c_stop();
return buffer;
}
void main()
{
///////////////////////INIT////////////////////////////
qn8007_write(QN8007_SYSTEM2, 0x80); //reset all registers to default
qn8007_write(QN8007_SYSTEM1, 0x43); //enter transmit
qn8007_write(QN8007_ANACTL1, 0x2B); //select 26MHz crystal
qn8007_write(QN8007_SYSTEM2, 0x01); //set preemphasis to 50uS
freq = freq * 10;
freq = ((freq - 7600) / 5); //626 for 107.3MHz (0x272 or 0b1001110010) lower 8bits are (0x72 or 0b01110010)
qn8007_write(QN8007_CH, (int8)freq);
tStep = qn8007_read(QN8007_CH_STEP);
tStep &= ~0x03;
tStep |= (((int8)(freq >> 8)) & 0x03);
qn8007_write(QN8007_CH_STEP, tStep);
qn8007_write(QN8007_PAC_TARGET, 70); //set power valid values from 31 to 131
//power = (0.37*PAC_TARGET+68)dB,PAC_TARGET range is 31-131
while(true)
{
}
} |
This is the qn8007.h file with definitions of the registers:
Code: |
/***********************************************************/
/*power = (0.37*PAC_TARGET+68)dB,PAC_TARGET range is 31-131*/
#define QN8007_TX_POWER_MIN 31
#define QN8007_TX_POWER_MAX 131
/***********************************************************/
/************QN8007 Address****************/
#define QN8007_ADDR_WRITE 0x56
#define QN8007_ADDR_READ 0x57
/******************************************/
/********QN8007 User Control Registers********/
#define QN8007_SYSTEM1 0x00
#define QN8007_SYSTEM2 0x01
#define QN8007_DEV_ADD 0x02
#define QN8007_ANACTL1 0x03
#define QN8007_REG_VGA 0x04
#define QN8007_CID1 0x05
#define QN8007_CID2 0x06
#define QN8007_I2S 0x07
#define QN8007_CH 0x08
#define QN8007_CH_START 0x09
#define QN8007_CH_STOP 0x0A
#define QN8007_CH_STEP 0x0B
#define QN8007_PAC_TARGET 0x0C
#define QN8007_TXAGC_GAIN 0x0D
#define QN8007_TX_FDEV 0x0E
#define QN8007_GAIN_TXPLT 0x0F
#define QN8007_RDSD0 0X10
#define QN8007_RDSD1 0x11
#define QN8007_RDSD2 0x12
#define QN8007_RDSD4 0x14
#define QN8007_RDSD5 0x15
#define QN8007_RDSD6 0x16
#define QN8007_RDSD7 0x17
#define QN8007_RDSFDEV 0x18
#define QN8007_CCA 0x19
#define QN8007_STATUS1 0x1A
#define QN8007_STATUS2 0x1B
#define QN8007_REG_XLT3 0x49
#define QN8007_PAC_CAL 0x59
#define QN8007_PAG_CAL 0x5A
/*********************************************/
// SYSTEM1
#define QN8007_RXREQ 0x80
#define QN8007_TXREQ 0x40
#define QN8007_CHSC 0x20
#define QN8007_STNBY 0x10
#define QN8007_RXI2S 0x08
#define QN8007_TXI2S 0x04
#define QN8007_RDSEN 0x02
#define QN8007_CCA_CH_DIS 0x01
// SYSTEM2
#define QN8007_SWRST 0x80
#define QN8007_RECAL 0x40
#define QN8007_FORCE_MO 0x20
#define QN8007_ST_MO_TX 0x10
#define QN8007_PETC 0x08
#define QN8007_RDSTXRDY 0x04
#define QN8007_TMOUT1 0x02
#define QN8007_TMOUT0 0x01
// channel
#define QN8007_CH_AUTO 0
#define QN8007_CH_USER 1 |
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19649
|
|
Posted: Thu Jan 02, 2025 6:06 am |
|
|
Well done tonkostz.
It is very nice to see code with a reasonable amount of documentation.
Hopefully this will allow Al, to see if his chip will work.
Happy New Year. |
|
|
Al in Michigan
Joined: 29 Dec 2024 Posts: 13 Location: michigan
|
|
Posted: Thu Jan 02, 2025 1:43 pm |
|
|
Thanks for the code. I'll need to translate that to my world but I think I see what you're doing with the read & write sequences. |
|
|
Al in Michigan
Joined: 29 Dec 2024 Posts: 13 Location: michigan
|
|
Posted: Thu Jan 02, 2025 4:38 pm |
|
|
OK , I'm not familiar with the i2c_xxxx calls used and searching returned no info. I translated to I2C usage that I'm familiar with using ESP32 library "wire.h". QN800X_I2C_ADDRESS is 0x2b
A sanity check by anyone familiar with both appreciated,
////////////////////////WRITE////
void qn8007_write(int Reg, int val)
{
i2c_start(); beginTransmission(QN800X_I2C_ADDRESS);
i2c_write(0x56); Wire.write(Reg);
i2c_write(val); Wire.write(val);
i2c_stop(); Wire.endTransmission();
}
////////////////////////READ//////
int qn8007_read(int Reg)
{
i2c_start(); Wire.beginTransmission(QN800X_I2C_ADDRESS);
i2c_write(0x56); Wire.write(0x56);
i2c_write(Reg); Wire.write(Reg);
i2c_start(); Wire.beginTransmission(QN800X_I2C_ADDRESS);
i2c_write(0x57); Wire.write(0x57);
Wire.requestFrom(QN800X_I2C_ADDRESS, 2);
buffer = i2c_read(0); int buffer=Wire.read();
i2c_stop(); Wire.endTransmission();
return buffer; return buffer;
} |
|
|
|