??? 09/23/04 07:30 Read: times |
#77990 - RE: problem with SPI & MAX6662 (at89s8252) Responding to: ???'s previous message |
hi,
You were right, Thanks. with small changes temperature sensor is working correctly (CPOL = 0 | CPHA = 0) but... ;) rtc chip is not. When data wires are connected i`m reading random values almost always 0x00. I have looked at DS1306 datasheet and found the Figure "TYPICAL OPERATING CIRCUIT" at page 1. It shows that SDI and SDO may be tied together. In fact, we come back to SPI configuration. Opposite to MAX6662, RTC requires CPOL = 0 and CPHA = 1 for SPI communication. Before you switch to 3-wire interface, try to utilize SPI. You see, 3-wire has some "uncompatibles" with SPI. For example, it sends LSB first so you will need re-arrange bits. In fact, 3-wire interface is the good candidate to be used with UART in mode 0 (shift register). But you need to check UART timings firstly because they are fixed from OSC frequency. If they are suitable and you have free UART, then just connect RTC SDI+SDO to RX and RTC SCK to TX and configure UART to mode 0. Then read AT89 Series Hardware Description about how to work with UART in mode 0. Be careful, it is not hard but different from other UART modes. What I may suggest for keep SPI usage: - implement slave select lines. MAX6662 has /CE input activated with low level and DS1306 has CE activated with high level. You may use two MCU pins to select one of devices on-line, or may connect both select lines together and tie to one pin of MCU. With last way, when one device is selected then other is passive. Here: set pin to 1 for DS1306 select and reset it to 0 for MAX6662. - switch CPHA bit to appropriate level for each device. Reset it to 0 for MAX6662 and set to 1 for DS1306. But here you must know important note: these bits must be manipulated only when SPI is at reset state (OFF). So I strongly recommend next way: 1a) [only if the common pin is used for both /CE and CE]: Select device which you need not with. For example, if you prepare MAX6662 communication then select DS1306 and vice versa. 1b) [if separate select pins are used]: Unselect both devices, i.e.: /CE=1, CE=0 2) disable SPI (SPE=0); 3) set CPHA to needed level; 4) enable SPI back; 5) select device you need communicate with. The step 1 is required because during SPI desabled, pins SCK,MISO,MOSI,SS go to states defined with port output latches and this may produce unexpected changes (for example, SCK line may produce a clock pulse). So in case 1b we disable both devices, in case 1a we temporaly select device which will be disabled some late at step 5. Regards, Oleg |
Topic | Author | Date |
problem with SPI & MAX6662 (at89s8252) | 01/01/70 00:00 | |
RE: problem with SPI & MAX6662 (at89s8252) | 01/01/70 00:00 | |
RE: problem with SPI & MAX6662 (at89s8252) | 01/01/70 00:00 | |
RE: problem with SPI & MAX6662 (at89s8252) | 01/01/70 00:00 | |
RE: problem with SPI & MAX6662 (at89s8252) | 01/01/70 00:00 | |
RE: problem with SPI & MAX6662 (at89s8252) | 01/01/70 00:00 | |
RE: problem with SPI & MAX6662 (at89s8252) | 01/01/70 00:00 | |
RE: problem with SPI & MAX6662 (at89s8252) | 01/01/70 00:00 | |
RE: problem with SPI & MAX6662 (at89s8252) | 01/01/70 00:00 | |
RE: problem with SPI & MAX6662 (at89s8252) | 01/01/70 00:00 | |
RE: problem with SPI & MAX6662 (at89s8252) | 01/01/70 00:00 | |
RE: problem with SPI & MAX6662 (at89s8252)![]() | 01/01/70 00:00 |