Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Multiple DS18S20 problem

Status
Not open for further replies.

povilas

Junior Member level 1
Junior Member level 1
Joined
Mar 4, 2013
Messages
17
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,382
Hello I am using Pic16f873 microcontroller and 6 ds18s20 thermometers. And programing with microC pro. And when I compile program and get replay "There is not enough ROM space".here is my source code:

Code:
// LCD ekrano prijungimai
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;

sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;

const unsigned short TEMP_RESOLUTION = 9;// nustatomas konstantos tipas ir sensoriaus tipas
char *text = "000.0";  //nustatomas kintamojo tipas ir pradinė jo reikšmė
unsigned katil, grizta, kamb, akum, saule, karsta, laukas;     //kintamasis temperatūros nuskaitymui
//unsigned s_0, s_1, s_2, s_3, s_4,s_5,s_6,s_7;

void Display_Temp(unsigned int temp2write) {
  const unsigned short RES_SHIFT = TEMP_RESOLUTION - 8;     //priklauso nuo sensoriaus rezoliucijos
  char temp_whole;
  unsigned int temp_fraction;
  int neigtemp = 1;

 // Tikrinti ar temperatūra nėra neigiama
  if (temp2write & 0x8000) {
     text[0] = '-';
     temp2write = ~temp2write + 1;
     neigtemp=1;
   }
  else {
     neigtemp=0;
   }
  // gauti kintamąji temp_whole
  temp_whole = temp2write >> RES_SHIFT ;
  if (!neigtemp)    {         // tikrinti kintamajį neigtemp
     if (temp_whole/100)     // Perversti temp_whole į vienetus
     text[0] = temp_whole/100 + 48;
     else
     text[0] = ' ';
   }
  text[1] = (temp_whole/10)%10+48;             // Gauti dešimčių skaičių
  text[2] =  temp_whole%10     + 48;             // Gauti vienetų skaičių

  // Gauti kintamojo temp_fraction vienetus po kablelio
  temp_fraction  = temp2write << (4-RES_SHIFT);   // rodo dešimtasias dalis
  temp_fraction &= 0x000F;
  temp_fraction *= 625;
  // Paversti kintamojo temp_fraction duomenis į vienetus
  text[4] =  temp_fraction/1000 + 48;         // Gauti vienetų skaičių po kablelio
  // Išvesti temperatūra į LCD ekraną.

  Lcd_Out(1, 1, "Temp:");
  Lcd_Out(2, 1, "Temp:");  // Išjungti kursorių
  // Išvedamas laipsnio ženklas ir celsijaus simbolis
  Lcd_Chr(1,11,223);
  Lcd_Chr(1,12,'C');
  Lcd_Chr(2,11,223);
  Lcd_Chr(2,12,'C');
  //Lcd_Out(3, 6,text);

}
 
void main() {

 //PORTB = 0;                // Reset port D
 TRISB = 0b01111111;
 ADCON1 = 7 ;

  Lcd_Init();                                    // Inicializuoti LCD
  Lcd_Cmd(_LCD_CLEAR);                           // Išvalyti LCD
  Lcd_Cmd(_LCD_CURSOR_OFF);


  //Duomenų nuskaitymo programa
  do {
  
          //katilo daviklis
    //Temperatūros nuskaitymas
   Ow_Reset(&PORTB, 6);
    Ow_Write(&PORTB, 6,0x55);
    Ow_Write(&PORTB, 6,0x10);
    Ow_Write(&PORTB, 6,0x30);
    Ow_Write(&PORTB, 6,0xC5);
    Ow_Write(&PORTB, 6,0xC8);
    Ow_Write(&PORTB, 6,0x00);
    Ow_Write(&PORTB, 6,0x00);
    Ow_Write(&PORTB, 6,0x00);
    Ow_Write(&PORTB, 6,0xC3);
    Ow_Write(&PORTB, 6, 0x44);                   // Issue command CONVERT_T
    Delay_us(600);

    Ow_Reset(&PORTB, 6);
    Ow_Write(&PORTB, 6,0x55);
    Ow_Write(&PORTB, 6,0x10);
    Ow_Write(&PORTB, 6,0x30);
    Ow_Write(&PORTB, 6,0xC5);
    Ow_Write(&PORTB, 6,0xC8);
    Ow_Write(&PORTB, 6,0x00);
    Ow_Write(&PORTB, 6,0x00);
    Ow_Write(&PORTB, 6,0x00);
    Ow_Write(&PORTB, 6,0xC3);
    Ow_Write(&PORTB, 6, 0xBE);

    katil =  Ow_Read(&PORTB, 6);
    katil = (Ow_Read(&PORTB, 6) << 8) + katil;

    //--- Format and display result on Lcd
    Display_Temp(katil);
    Lcd_Out(1, 6,text);

    //Delay_ms(120);

             //grižtamasis daviklis
   Ow_Reset(&PORTB, 6);
    Ow_Write(&PORTB, 6,0x55);
    Ow_Write(&PORTB, 6,0x10);
    Ow_Write(&PORTB, 6,0x31);
    Ow_Write(&PORTB, 6,0xC5);
    Ow_Write(&PORTB, 6,0xC8);
    Ow_Write(&PORTB, 6,0x00);
    Ow_Write(&PORTB, 6,0x00);
    Ow_Write(&PORTB, 6,0x00);
    Ow_Write(&PORTB, 6,0xF4);
    Ow_Write(&PORTB, 6, 0x44);                   // Issue command CONVERT_T
    Delay_us(600);

    Ow_Reset(&PORTB, 6);
    Ow_Write(&PORTB, 6,0x55);
    Ow_Write(&PORTB, 6,0x10);
    Ow_Write(&PORTB, 6,0x31);
    Ow_Write(&PORTB, 6,0xC5);
    Ow_Write(&PORTB, 6,0xC8);
    Ow_Write(&PORTB, 6,0x00);
    Ow_Write(&PORTB, 6,0x00);
    Ow_Write(&PORTB, 6,0x00);
    Ow_Write(&PORTB, 6,0xF4);

    Ow_Write(&PORTB, 6, 0xBE);

    grizta =  Ow_Read(&PORTB, 6);
    grizta = (Ow_Read(&PORTB, 6) << 8) + grizta;

    //--- Format and display result on Lcd
    Display_Temp(grizta);
    Lcd_Out(2, 6,text);

    //Delay_ms(120);
    //karšto vandens
    Ow_Reset(&PORTB, 6);
    Ow_Write(&PORTB, 6,0x55);
    Ow_Write(&PORTB, 6,0x10);
    Ow_Write(&PORTB, 6,0x32);
    Ow_Write(&PORTB, 6,0xC5);
    Ow_Write(&PORTB, 6,0xC8);
    Ow_Write(&PORTB, 6,0x00);
    Ow_Write(&PORTB, 6,0x00);
    Ow_Write(&PORTB, 6,0x00);
    Ow_Write(&PORTB, 6,0xAD);
    Ow_Write(&PORTB, 6, 0x44);                   // Issue command CONVERT_T
    Delay_us(600);

    Ow_Reset(&PORTB, 6);
    Ow_Write(&PORTB, 6,0x55);
    Ow_Write(&PORTB, 6,0x10);
    Ow_Write(&PORTB, 6,0x32);
    Ow_Write(&PORTB, 6,0xC5);
    Ow_Write(&PORTB, 6,0xC8);
    Ow_Write(&PORTB, 6,0x00);
    Ow_Write(&PORTB, 6,0x00);
    Ow_Write(&PORTB, 6,0x00);
    Ow_Write(&PORTB, 6,0xAD);

    Ow_Write(&PORTB, 6, 0xBE);

    karsta =  Ow_Read(&PORTB, 6);
    karsta = (Ow_Read(&PORTB, 6) << 8) + karsta;

    //--- Format and display result on Lcd
    Display_Temp(karsta);
    //Lcd_Out(3, 6,text);
    
    //kambario daviklis
    
    Ow_Reset(&PORTB, 6);
    Ow_Write(&PORTB, 6,0x55);
    Ow_Write(&PORTB, 6,0x10);
    Ow_Write(&PORTB, 6,0x33);
    Ow_Write(&PORTB, 6,0xC5);
    Ow_Write(&PORTB, 6,0xC8);
    Ow_Write(&PORTB, 6,0x00);
    Ow_Write(&PORTB, 6,0x00);
    Ow_Write(&PORTB, 6,0x00);
    Ow_Write(&PORTB, 6,0x9A);
    Ow_Write(&PORTB, 6, 0x44);                   // Issue command CONVERT_T
    Delay_us(600);

    Ow_Reset(&PORTB, 6);
    Ow_Write(&PORTB, 6,0x55);
    Ow_Write(&PORTB, 6,0x10);
    Ow_Write(&PORTB, 6,0x33);
    Ow_Write(&PORTB, 6,0xC5);
    Ow_Write(&PORTB, 6,0xC8);
    Ow_Write(&PORTB, 6,0x00);
    Ow_Write(&PORTB, 6,0x00);
    Ow_Write(&PORTB, 6,0x00);
    Ow_Write(&PORTB, 6,0x9A);

    Ow_Write(&PORTB, 6, 0xBE);

    kamb =  Ow_Read(&PORTB, 6);
    kamb = (Ow_Read(&PORTB, 6) << 8) + kamb;

    //--- Format and display result on Lcd
    Display_Temp(kamb);
    //Lcd_Out(4, 6,text);
    
    //akumuliacinis daviklis
    
    Ow_Reset(&PORTB, 6);
    Ow_Write(&PORTB, 6,0x55);
    Ow_Write(&PORTB, 6,0x10);
    Ow_Write(&PORTB, 6,0x34);
    Ow_Write(&PORTB, 6,0xC5);
    Ow_Write(&PORTB, 6,0xC8);
    Ow_Write(&PORTB, 6,0x00);
    Ow_Write(&PORTB, 6,0x00);
    Ow_Write(&PORTB, 6,0x00);
    Ow_Write(&PORTB, 6,0x1F);
    Ow_Write(&PORTB, 6, 0x44);                   // Issue command CONVERT_T
    Delay_us(600);

    Ow_Reset(&PORTB, 6);
    Ow_Write(&PORTB, 6,0x55);
    Ow_Write(&PORTB, 6,0x10);
    Ow_Write(&PORTB, 6,0x34);
    Ow_Write(&PORTB, 6,0xC5);
    Ow_Write(&PORTB, 6,0xC8);
    Ow_Write(&PORTB, 6,0x00);
    Ow_Write(&PORTB, 6,0x00);
    Ow_Write(&PORTB, 6,0x00);
    Ow_Write(&PORTB, 6,0x1F);

    Ow_Write(&PORTB, 6, 0xBE);

    akum =  Ow_Read(&PORTB, 6);
    akum = (Ow_Read(&PORTB, 6) << 8) + akum;
    Display_Temp(laukas);
   // Lcd_Out(1, 6,text);
    //--- Format and display result on Lcd

    //saules kolektoriaus daviklis
    Ow_Reset(&PORTB, 6);
    Ow_Write(&PORTB, 6,0x55);
    Ow_Write(&PORTB, 6,0x10);
    Ow_Write(&PORTB, 6,0x35);
    Ow_Write(&PORTB, 6,0xC5);
    Ow_Write(&PORTB, 6,0xC8);
    Ow_Write(&PORTB, 6,0x00);
    Ow_Write(&PORTB, 6,0x00);
    Ow_Write(&PORTB, 6,0x00);
    Ow_Write(&PORTB, 6,0x28);
    Ow_Write(&PORTB, 6, 0x44);                   // Issue command CONVERT_T
    Delay_us(600);

    Ow_Reset(&PORTB, 6);
    Ow_Write(&PORTB, 6,0x55);
    Ow_Write(&PORTB, 6,0x10);
    Ow_Write(&PORTB, 6,0x35);
    Ow_Write(&PORTB, 6,0xC5);
    Ow_Write(&PORTB, 6,0xC8);
    Ow_Write(&PORTB, 6,0x00);
    Ow_Write(&PORTB, 6,0x00);
    Ow_Write(&PORTB, 6,0x00);
    Ow_Write(&PORTB, 6,0x28);

    Ow_Write(&PORTB, 6, 0xBE);

    saule =  Ow_Read(&PORTB, 6);
    saule = (Ow_Read(&PORTB, 6) << 8) + saule;
    Display_Temp(laukas);
   // Lcd_Out(1, 6,text);

          //lauko daviklis
    Ow_Reset(&PORTB, 6);
    Ow_Write(&PORTB, 6,0x55);
    Ow_Write(&PORTB, 6,0x10);
    Ow_Write(&PORTB, 6,0x36);
    Ow_Write(&PORTB, 6,0xC5);
    Ow_Write(&PORTB, 6,0xC8);
    Ow_Write(&PORTB, 6,0x00);
    Ow_Write(&PORTB, 6,0x00);
    Ow_Write(&PORTB, 6,0x00);
    Ow_Write(&PORTB, 6,0x28);
    Ow_Write(&PORTB, 6, 0x44);                   // Issue command CONVERT_T
    Delay_us(600);

    Ow_Reset(&PORTB, 6);
    Ow_Write(&PORTB, 6,0x55);
    Ow_Write(&PORTB, 6,0x10);
    Ow_Write(&PORTB, 6,0x36);
    Ow_Write(&PORTB, 6,0xC5);
    Ow_Write(&PORTB, 6,0xC8);
    Ow_Write(&PORTB, 6,0x00);
    Ow_Write(&PORTB, 6,0x00);
    Ow_Write(&PORTB, 6,0x00);
    Ow_Write(&PORTB, 6,0x28);

    Ow_Write(&PORTB, 6, 0xBE);

    laukas =  Ow_Read(&PORTB, 6);
    laukas = (Ow_Read(&PORTB, 6) << 8) + laukas;
    Display_Temp(laukas);
   // Lcd_Out(1, 6,text);

  } while (1);
}

can anyone help to solve this problem?
 
Last edited by a moderator:

HI
I compile your program in MikroC and compiled it, the result was this two error : expexted but LCD_RS found and Internal error but no not enough RAM!!!!!!
 

HI
I compile your program in MikroC and compiled it, the result was this two error : expexted but LCD_RS found and Internal error but no not enough RAM!!!!!!

Hi, I compiled again and the same "" there is not enough ROM space".
 

Maybe you have selected the wrong PIC for the project. See Project>Edit Project...
If PIC is right then memory is not sufficient for your program. Try using maximum optimization. If that doesn't work change your PIC which has more memory.
 

Maybe you have selected the wrong PIC for the project. See Project>Edit Project...
If PIC is right then memory is not sufficient for your program. Try using maximum optimization. If that doesn't work change your PIC which has more memory.

Maybe PIC is too small, but I am looking for advice. how can I do maximum optimization, I saw something with switch case commands, but I am not smart enough to solve this.
 

This is NOT a full program and it isn't written for MikroC but it shows an alternative and much smaller way of handling multiple sensors. The sensors serial numbers are in the const array, obviously, insert your own numbers instead.
It is an extract from a working system but I cannot show all the code for legal reasons. It should give some ideas though. The 1-Wire functions are from the WIZ-C library and the results of readings from the DS18S20s are saved in the Rx1WData character array.

Code:
const char Serial[8][8] = {{0x28,0xAA,0x5F,0x9B,0x00,0x00,0x00,0x02},
                                                    {0x28,0x35,0x60,0x9B,0x00,0x00,0x00,0x7C},
                                                    {0x28,0x8E,0xB9,0x9B,0x00,0x00,0x00,0x2E},
                                                    {0x28,0x01,0xA2,0x9B,0x00,0x00,0x00,0xEC},
                                                    {0x22,0xC8,0x86,0x12,0x00,0x00,0x00,0xC3},
                                                    {0x22,0x7A,0x90,0x12,0x00,0x00,0x00,0x4A},
                                                    {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
                                                    {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}};

void MeasureTemp(int Sensor)
{
    //send convert command to sensor
    Select1WDevice(Sensor);
    Tx1Wire(0x44);
    Wait(750);

    //read back sensor selected by serial number
    Select1WDevice(Sensor);    //select sensor
    Tx1Wire(0xBE);            //read scratchpad
    
    //read from the scratchpad and store the temperature bytes
    for(Rx1WPtr = 0; Rx1WPtr < 9; Rx1WPtr++)
    {
        Rx1WData[Rx1WPtr] = Rx1Wire();
    }
}


//send a 'match ROM' command and serial number to the sensor
void Select1WDevice(int x)
{
    int i;
    ResetCheck1W();        
    Tx1Wire(0x55); //match ROM command
    for(i = 0; i < 8; i++)
    {
        Tx1Wire(Serial[x][i]);
    }
}


Ugh! Tab settings in the original make all the serial line up - sorry if they are shifted to one side. Incidentally, the PIC was a 16F628A.

Brian.
 
Brian, thank you very much for answer, it was very helpful. know i have another problem. here is my source code now: initialization
Code:
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;\
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;

sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;

int i;
char kint1;
char addr[] = {0x55,0x10,0x30,0xC5,0xC8,0x00,0x00,0x00,0xC3};
const unsigned short TEMP_RESOLUTION = 9;// nustatomas konstantos tipas ir sensoriaus tipas
char *text = "000.0";  //nustatomas kintamojo tipas ir pradinė jo reikšmė
unsigned katil, grizta, kamb, akum, saule, karsta, laukas;     //kintamasis temperatūros nuskaitymui
//unsigned s_0, s_1, s_2, s_3, s_4,s_5,s_6,s_7;

void disp_temp
Code:
void Display_Temp(unsigned int temp2write) {
  const unsigned short RES_SHIFT = TEMP_RESOLUTION - 8;     //priklauso nuo sensoriaus rezoliucijos
  char temp_whole;
  unsigned int temp_fraction;
  int neigtemp = 1;

 // Tikrinti ar temperatūra nėra neigiama
  if (temp2write & 0x8000) {
     text[0] = '-';
     temp2write = ~temp2write + 1;
     neigtemp=1;
   }
  else {
     neigtemp=0;
   }
  // gauti kintamąji temp_whole
  temp_whole = temp2write >> RES_SHIFT ;
  if (!neigtemp)    {         // tikrinti kintamajį neigtemp
     if (temp_whole/100)     // Perversti temp_whole į vienetus
     text[0] = temp_whole/100 + 48;
     else
     text[0] = ' ';
   }
  text[1] = (temp_whole/10)%10+48;             // Gauti dešimčių skaičių
  text[2] =  temp_whole%10     + 48;             // Gauti vienetų skaičių

  // Gauti kintamojo temp_fraction vienetus po kablelio
  temp_fraction  = temp2write << (4-RES_SHIFT);   // rodo dešimtasias dalis
  temp_fraction &= 0x000F;
  temp_fraction *= 625;
  // Paversti kintamojo temp_fraction duomenis į vienetus
  text[4] =  temp_fraction/1000 + 48;         // Gauti vienetų skaičių po kablelio
  // Išvesti temperatūra į LCD ekraną.

  Lcd_Out(1, 1, "Temp:");
  Lcd_Out(2, 1, "Temp:");  // Išjungti kursorių
  // Išvedamas laipsnio ženklas ir celsijaus simbolis
  Lcd_Chr(1,11,223);
  Lcd_Chr(1,12,'C');
  Lcd_Chr(2,11,223);
  Lcd_Chr(2,12,'C');
  Lcd_Out(3, 6,text);
main
Code:
void main(){
PORTB = 0;                // Reset port D
 TRISB = 0b01111111;
 PORTC = 0;
 TRISC = 0b00000000;
 ADCON1 = 7 ;

  Lcd_Init();                                    // Inicializuoti LCD
  Lcd_Cmd(_LCD_CLEAR);                           // Išvalyti LCD
  Lcd_Cmd(_LCD_CURSOR_OFF);
do{
 Ow_Reset(&PORTB, 6);   
 [B]for ( i = 0; i<=8;i++   ) 
 {
 kint1 =  addr[i];
  Ow_Write(&PORTB, 6,kint1);[/B]
  }                 
    Ow_Write(&PORTB, 6, 0x44);                   // Issue command CONVERT_T
    Delay_us(600);
    Ow_Reset(&PORTB, 6);
  [B]for( i = 0; i<=8;i++  )
 {
 Ow_Write(&PORTB, 6,addr[i]);
  }[/B]

  Ow_Write(&PORTB, 6, 0xBE);

   laukas =  Ow_Read(&PORTB, 6);
    laukas = (Ow_Read(&PORTB, 6) << 8) + laukas;
    Display_Temp(laukas);
    Lcd_Out(1, 6,text);
   }while(1);
   }
Now I am using operation for. compiles great, but In Proteus not working, showing -00,5, -01,0, and correct temperature, and writing "RAM COMMAND UNSUPPORTED".
I think this is something easy I don't see. Can help to solve this issue?
 

I do not have Proteus to check for you but I suspect you are sending one byte too many to the sensor. You appear to be sending the comand followed by 9 address bytes instead of 8.

Brian.
 
I do not have Proteus to check for you but I suspect you are sending one byte too many to the sensor. You appear to be sending the comand followed by 9 address bytes instead of 8.

Brian.

There is OK. 9 bytes because I sent 0X55 with 8 bytes address.
 

Sorry, I did not notice you had included the "MATCH ROM" command in the address array.

I can't see anything wrong with your code but as I explained, I can not compile it or simulate it here. Can you tell where the error message is coming from, is "RAM COMMAND UNSUPPORTED" refering to the RAM in the LCD controller or the RAM in the DS18S20?

If it helps, this is my version of the data to string routine:
Code:
//create and send result to host as a string
void TxResult()
{
	//convert measurement bytes to a floating point temperature string
	Rx1WRaw = (unsigned int)Rx1WData[0] | ((unsigned int)Rx1WData[1] << 8);
	Rx1WSign = '+'; 
	if((Rx1WData[1] & 0xF0) == 0xF0)
	{ 
		Rx1WSign='-'; 
		Rx1WRaw = (~Rx1WRaw) + 1 ; 
	} 

	Rx1WInt = ((Rx1WRaw >> 4) & 0x7F); 
	Rx1WFloat = ((Rx1WRaw & 0x000F) * 625); 

	sprintf(TxBuffer,"%c%d.%04d",Rx1WSign,Rx1WInt,Rx1WFloat);	

	//send string to host system
	TxPtr = 0;
	while(TxBuffer[TxPtr])
	{
			AddTx(TxBuffer[TxPtr++]);
	}

	AddTx(0x0D);
}

TxBuffer[] is a char array to hold the result text. I was sending the data over a serial link instead of using an LCD but the ASCII format is the same.

Brian.
 
I'm not sure how Proteus does error checking to produce the message so I can only assume you are either sending a command it doesn't recognize or sending more bytes than it can use. I can see a potential bug in the code due to conversion time at highest resolution, you allow 600uS but the data sheet specifies 750uS minimum although I doubt that would be the cause. It's always better to monitor the DQ line after starting a conversion so the device tells you when it's ready to read, that works on all resolutions and gives fastest response.

Can you trace the logic signals to and from the DS18S20 to see what is actually being transferred?

Brian.
 
Thank you Brian very very much for your time and help, it was very helpful. I solved it my self it needed just to write a clean code and that's all. working very good :))
 

I've never worked on SD card interfaces so I can't give any examples but they should be easy enough to work with. They use SPI to communicate but you have to be careful with the interface voltage which is 3.3V maximum. You PIC may work at 3.3V in which case you can connect them directly together but if your PIC uses 5V you need a level translating circuit.

Brian.
 

With schematics everything is OK, but software is difficult to me :)
 

Maybe someone with more experience of SD cards will help further but I can tell you that SPI is one of the simplest protocols to write code for. It has a 'data in' and a 'data out' pin so there's no need to worry about changing port direction and all you do is 1. enable the device, 2. send it command bits, 3. keep clocking to read the reply on the output pin, 4. disable the device. All bit transfers are synchronous to the clock and there is only one master (the PIC). Very easy to do in software or you can use the MSSP module in the PIC if it has one.

Brian.
 

Thank for answer. Another problem, I have 2 projects, first temperature and relays control, second RTC with ds1307. how can I write them together that It work like separated projects? sorry for language :)

Povilas.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top