salihonur
Newbie level 5
- Joined
- Jul 13, 2011
- Messages
- 9
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,383
Hi,
I have a strange problem about LTC2440. Proteus simulation runs perfect, but the SDO pin of ltc2440 gives always logic high at real circuit. I watch the waveform on the scope and see same as this (Note: I draw short form of the wave 4 clock pulses instead of 8 bit).
SDO ___-------------------------------------------------____
SCK _____-_-_-_-___-_-_-_-___-_-_-_-___-_-_-_-__________ (actually 8 pulses in each clock group)
CS --________________________________________----------
I think the problem is about physical. I have added the schematic and source code. How can I fix this problem?
I have a strange problem about LTC2440. Proteus simulation runs perfect, but the SDO pin of ltc2440 gives always logic high at real circuit. I watch the waveform on the scope and see same as this (Note: I draw short form of the wave 4 clock pulses instead of 8 bit).
SDO ___-------------------------------------------------____
SCK _____-_-_-_-___-_-_-_-___-_-_-_-___-_-_-_-__________ (actually 8 pulses in each clock group)
CS --________________________________________----------
I think the problem is about physical. I have added the schematic and source code. How can I fix this problem?
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 #include <18F2520.h> #device *=16 #fuses INTRC_IO,NOWDT,NOMCLR,PUT,PROTECT,CPB,NOBROWNOUT #use delay(clock=32000000,restart_wdt) #use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8) //#fuses INTRC_IO,NOMCLR,WDT,WDT64,NOBROWNOUT,PUT,NOLVP,CPB,CPD,PROTECT,NOWRT // Port ve Pin Tanımlamaları =================================================== #define ADC_CS_ PIN_C2 #define BUSY PIN_C1 #byte PORTA = 0xF80 #byte PORTB = 0xF81 #byte PORTC = 0xF82 #byte TRISA = 0xF92 #byte TRISB = 0xF93 #byte TRISC = 0xF94 #byte SSPSTAT = 0xFC7 #byte SSPCON1 = 0xFC6 #bit CKE = SSPSTAT.6 #bit CKP = SSPCON1.4 #bit LTC_BUSY = PORTC.1 #bit LTC_CS = PORTC.2 #bit LTC_SCK = PORTC.3 #bit LTC_SDO = PORTC.4 #bit LTC_SDI = PORTC.5 #bit BT_SET_OFFSET = PORTC.0 #bit BT_SET_REF = PORTC.6 #bit OFFSET_SETTING = PORTA.3 #bit ILETISIM_LED = PORTB.3 //============================================================================== #bit IA4421_SDI = PORTA.1 #bit IA4421_SDO = PORTA.7 //0 #bit IA4421_SCK = PORTA.2 #bit IA4421_NSEL = PORTA.5 #bit IA4421_NFFS = PORTA.6 //3 #bit IA4421_NFFS_D = TRISA.6 //3 #bit IA4421_NIRQ = PORTA.4 //=========================================================================== int TxPacket[10],RxPacket[10],Paket[80],ALICI_ID_H,ALICI_ID_L,VERICI_ID_H,VERICI_ID_L,LOAD_KG_8L,LOAD_KG_8H; int16 Frequency_cmd,Transmitter_control_cmd,Data_rate_cmd; //------------------------------------------------------- #define EPROM_OFFSET_ADDRESS 0x00 #define EPROM_REF_POINT_ADDRESS 0x04 #define EPROM_REF_VALUE_ADDRESS 0x09 //------------------------------------------------------- float data,calc; int32 offset, ref_adc, ref_kg, load_kg; struct fourbytes { int8 d0; int8 d1; int8 d2; int8 d3; }; union { signed int32 bits32; struct fourbytes by; } load; //------------------------------------------------------- #include <math.h> #include <stdio.h> #define RF_CHANNEL 39 #define ID_HIGH 14 #define ID_LOW 14 #include <IA4421_4th_GENERATION.h> //=========================================================================== //=========================================================================== // MAIN Routine void main(void) { int16 i,RF_Tolerans; //--------------------------------------------------------------------------- setup_oscillator(OSC_32MHZ); restart_wdt(); set_tris_a(0x5B); set_tris_b(0x61); set_tris_c(0x02); //14 PORTA=0; PORTB=0; PORTC=0; output_high(ADC_CS_); setup_spi(SPI_MASTER|SPI_L_TO_H|SPI_CLK_DIV_16|SPI_SS_DISABLED); CKP = 0; // Set up clock edges - clock idles low, data changes on CKE = 1; // falling edges, valid on rising edges. enable_interrupts(global); restart_wdt(); IA4421_init(RF_CHANNEL,7); Set_RF_Rx(); restart_wdt(); delay_ms(100); restart_wdt(); VERICI_ID_H = ID_HIGH; VERICI_ID_L = ID_LOW; ALICI_ID_H = VERICI_ID_H; ALICI_ID_L = VERICI_ID_L; IA4421_init(RF_CHANNEL,7); Set_RF_Rx(); while(1) { i++; if(RF_Tolerans<250) RF_Tolerans++; if(RF_Tolerans>249 && !Receive_Packet()) { ILETISIM_LED=(i/1000)%2; load_kg=0; // output_low(ADC_CS_); LTC_CS=0; load.by.d3 = spi_read(0x78); load.by.d2 = spi_read(0x78); load.by.d1 = spi_read(0x78); load.by.d0 = spi_read(0x78); LTC_CS=1; // output_high(ADC_CS_); // Subtract offset (result is in 2’s complement) load.bits32 = load.bits32 - 0x20000000; data = (float) load.bits32; // cast as float // calc=((data-offset)*max_kg)/(max_adc-offset); calc=ref_kg*(data-offset)/(ref_adc-offset); load_kg=load.bits32; // load_kg=calc; // LOAD_KG = 1000; LOAD_KG_8L=make8(LOAD_KG,0); LOAD_KG_8H=make8(LOAD_KG,1); restart_wdt(); } if(Receive_Packet()) { RF_Tolerans=0; ILETISIM_LED=!ILETISIM_LED; if(RxPacket[4]==0x07) { Set_RF_Tx(); restart_wdt(); TxPacket[4] = 0x06; // KOMUT TxPacket[5] = LOAD_KG_8L; // BİLGİ TxPacket[6] = LOAD_KG_8H; // BİLGİ TxPacket[7] = make8(LOAD_KG,2); // BİLGİ TxPacket[8] = make8(LOAD_KG,3); // BİLGİ TxPacket[9] = CALCULATE_CRC(TxPacket,9); // CRC Send_Data(10); restart_wdt(); Set_RF_Rx(); restart_wdt(); } } restart_wdt(); }//end of while } //===========================================================================