Reply
Posts: 22
Registered: ‎07-01-2013

ClockBuilderPro generates 16-bit address register map

Hi,

I try to configure Si5351A-B via I2C.

I use ClockBuilderPro v2.16.1 to generate register map.

 

ClockBuilderPro -> Export -> "Register file" tab -> "C Code Header File" option -> Save to file.

Open saved file.

 

#define SI5351A_REVB_REG_CONFIG_NUM_REGS				45

typedef struct
{
	unsigned int address; /* 16-bit register address */
	unsigned char value; /* 8-bit register data */

} si5351a_revb_register_t;

si5351a_revb_register_t const si5351a_revb_registers[SI5351A_REVB_REG_CONFIG_NUM_REGS] =
{
	{ 0x0002, 0x53 },
	{ 0x0003, 0x00 },
	{ 0x0007, 0x00 },
...

 

Register address is 16-bit long.

 

Si5351A/B/C-B rev1.0, page 17

A write command consists of a 7-
bit device (slave) address + a write bit, an 8-bit register address, and 8 bits of data

 

Why ClockBuilderPro generates register map in incorrect format?

 

Posts: 471
Registered: ‎01-18-2004

Re: ClockBuilderPro generates 16-bit address register map

[ Edited ]

My guess is that the 5351 works like the 5344 and the other SiLabs register-based programmable clock generators and oscillators. The 5344 has so many registers that it uses the concept of "pages" to organize them, and you have to write the page select before you program a register.

 

Since the 5351's register set fits entirely in a 256-address space (8 bit register address), the page select byte of each register address is 0.

 

That said, I agree with you, and Clock Builder should be changed so that it outputs one-byte register values in the headers.

 

You can do a couple of things:

 

  1. Edit the header file generated by Clock Builder so that the address member of the si5351b_revb_register_t structure is an unsigned char, and then make all of the addresses in the big list eight bits wide by deleting the upper 00 in each.
  2. When you access, from that big structure/table. each register, lop off the upper byte of the address. 

Number 1 saves you bytes in your code space flash, as you no longer have to save the unnecessary upper byte of each register address. But if you modify the Clock Builder project and then regenerate the header, your changes go away.

 

Number 2 is simpler if you think you have to update the Clock Builder project and you plenty of flash.

 

I have code that does #2, I'll post it after cleaning it up.

Posts: 22
Registered: ‎07-01-2013

Re: ClockBuilderPro generates 16-bit address register map

Hi Andy!

Thanks for your reply.

 

I use #2:

i2c.write(I2C_ADDR, si5351a_revb_registers[i].address & 0xFF, si5351a_revb_registers[i].value);

 

 

Highlighted
Posts: 471
Registered: ‎01-18-2004

Re: ClockBuilderPro generates 16-bit address register map


Roman wrote:

Hi Andy!

Thanks for your reply.

 

I use #2:

i2c.write(I2C_ADDR, si5351a_revb_registers[i].address & 0xFF, si5351a_revb_registers[i].value);

 

 


That should work; I assume that the second parameter in that function call wants a uint8_t or an unsigned char. I always do an explicit typecast, which I think makes the 0xFF superfluous. (Ah, the joys of C ...)