View previous topic :: View next topic |
Author |
Message |
HucK
Joined: 18 Feb 2004 Posts: 3
|
Max3100 Programming |
Posted: Fri Feb 20, 2004 11:38 pm |
|
|
I'm trying to configure this chip with 2 bytes abd 2 spi_write(), I can't say if he write well but i can only read the upper bits of the read configuration register. So if you have any suggestion or example on how to write 16 bits in one shot or how to use the MAX3100 with CCS, It will be great. Thanks... |
|
|
plehman
Joined: 18 Feb 2004 Posts: 12
|
|
Posted: Sat Feb 21, 2004 10:48 am |
|
|
If I understand correctly, you want to configure the MAX3100. I've used the MAX3110 before (close to the same part).
Note that spi_write() only uses 8-bit ints, so you need multiple writes to get the full configuration word to the part. The order of operations will likely be as follows:
- Bring the Chip Select LOW (Active)
- Write the MSB of the Write Configuration Word (see pg.8 of data sheet)
- Write the LSB of the Write Configuration Word (also on pg.8)
- Bring the Chip Select HIGH (Inactive)
I would probably delay a while to allow the part to configure itself and reset the baud rate generators, etc. and then try to read the Read Configuration Word to determine if it programmed correctly.
As far as example code, I would imaging something like the following would work:
long MAX3100_WriteConfig;
long MAX3100_ReadConfig;
int Temp[2];
MAX3100_WriteCofig = 0xC00A; // LS Nibble is Baud Rate
bit_clear(MAX3100_CHIP_SELECT);
spi_write(make8(MAX3100_WriteConfig,1));
spi_write(make8(MAX3100_WriteConfig,0));
bit_set(MAX3100_CHIP_SELECT);
delay_us(100);
bit_clear(MAX3100_CHIP_SELECT);
Temp[1] = spi_write(0x40);
Temp[2] = spi_write(0x00);
bit_set(MAX3100_CHIP_SELECT);
MAX3100_ReadConfig = make16(Temp[1], Temp[2]);
Note that the Write and Read Configuration words may differ in the top 2 bits depending on data available in the part, etc. Also, if you are having problems, verify that the SPI interface is correctly cofigured for the proper SPI Mode.
hope that helps. |
|
|
Guest Guest
|
SPI write |
Posted: Sat Feb 21, 2004 12:22 pm |
|
|
Huck -
I had troubles with SPI_WRITE with MAX parts in the past, while my "bit banging" routines worked fine. Wasn't till I hooked up an o'scope on the CLK and DATA lines that I saw the relationship between clock and data for the built-in SPI function didn't match my bit banging routines. I then saw that there are more options in the device.h file for SPI than are in the CCS manual. I played with the options until the clock did what I wanted to wrt the data. Worked fine after that. The manual stinks in many cases, and they don't mention some of the subtle points - like does the SPI clock go high after the data is set, does it go low, etc. The setup_spi options for controlling this are available - but it wasn't in the manual back then - it was in the *.h file!
HTH
Bill |
|
|
HucK
Joined: 18 Feb 2004 Posts: 3
|
|
Posted: Sat Feb 21, 2004 8:27 pm |
|
|
That's my code, I'm trying to read the congiguration but it returns me 0x4200, so where is the baud ???
Code: | void main()
{
long MAX3100_WriteConfig;
long MAX3100_ReadConfig;
int8 Temp[2];
setup_spi(SPI_MASTER | SPI_L_TO_H | SPI_CLK_DIV_16);
delay_us(100);
do
{
MAX3100_WriteConfig = 0xC00B; // LS Nibble is Baud Rate
output_low(MAX3100_SELECT);
delay_us(100);
Temp[0]=spi_read(make8(MAX3100_WriteConfig,1));
Temp[1]=spi_read(make8(MAX3100_WriteConfig,0));
output_high(MAX3100_SELECT);
delay_us(100);
output_low(MAX3100_SELECT);
Temp[0]=spi_read(0x40);
Temp[1]=spi_read(0x00);
output_high(MAX3100_SELECT);
MAX3100_ReadConfig = make16(Temp[0], Temp[1]);
delay_us(100);
}while(1);
} |
|
|
|
HucK
Joined: 18 Feb 2004 Posts: 3
|
It seems to resolve my problem, but i don't know why. |
Posted: Sat Feb 21, 2004 8:37 pm |
|
|
setup_spi(SPI_MASTER | SPI_XMIT_L_TO_H | SPI_CLK_DIV_16);
I would like to thank CCS for their great documentation ... |
|
|
|