CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

problem with QEI and int_rda on PIC18F4431

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
ntrungtruc2003



Joined: 16 Feb 2011
Posts: 42

View user's profile Send private message

problem with QEI and int_rda on PIC18F4431
PostPosted: Thu May 17, 2012 9:38 am     Reply with quote

Dear Sir
I am using the QEI module of the PIC 18F4431 for receiving signal A,B,Z encoder. It's pretty good. After that I sent successfully the value counter encoder to Hyper Terminal by using printf().

I try to use int_rda interrupt to receive the character value from Hyper Terminal by using getc() but couldn't be successful.

If I dont use QEI module I can receive the value from Hyper Terminal normally.

Somebody can teach me how to use int_rda in QEI module.

In the following code is referenced from Kenny.
Code:

#include <18F4431.h>
#use delay(clock=20000000)
#include <LCD_TM.c>
#use fast_io(a)       
#fuses HS,NOWDT,PUT,BROWNOUT,NOLVP,PWMPIN
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,ERRORS)

//configuracoes QEI
// Definitions
#byte QEICON      = 0xFB6  // Quadrature Encoder Interface control register
#byte DFLTCON     = 0xF60  // Digital filter control register
#byte POSCNTH     = 0xF67  // Position register high byte
#byte POSCNTL     = 0xF66  // Position register low byte
//#BYTE CAP2BUFL=0xF66 // position counter
//#BYTE CAP2BUFH=0xF67
#BYTE CAP3BUFL=0xF64  //max count
#BYTE CAP3BUFH=0xF65
#bit Direction  = 0xFB6.5
#define BUFFER_SIZE 32
#define bkbhit (next_in!=next_out)
BYTE buffer[BUFFER_SIZE];
BYTE next_in = 0;
BYTE next_out = 0;
byte c;

union
{
   int8 bytes[2];
   int16 word;
} position_union;

#int_rda
void serial_isr() {
 int t;

   buffer[next_in]=getc();
 t=next_in;
next_in=(next_in+1) % BUFFER_SIZE;
if(next_in==next_out)
  next_in=t;           // Buffer full !!
   
}

BYTE bgetc() {
   BYTE c;

   while(!bkbhit) ;
   c=buffer[next_out];
   next_out=(next_out+1) % BUFFER_SIZE;
   return(c);
}

void main(void) {   

lcd_init();   
   
   QEICON =0b10110100;     //  11000  quad in x4 mode,INDX reset the position counters 
   DFLTCON = 0b00111011;      //110001 noise filter on QEA, QEB,, 1:2 clock
   //CAP3BUFL=0XFF;     //MAXCNT
   //CAP3BUFH=0XFF;
   //POSCNTH=0;
   //POSCNTL=0;
  // enable_interrupts(INT_IC3DR);
  enable_interrupts (INT_IC2QEI);
   enable_interrupts(int_rda);
  enable_interrupts(GLOBAL);
 
  while(TRUE)
   {
      position_union.bytes[0] = POSCNTL;
      position_union.bytes[1] = POSCNTH;
      // Workaround for hardware bug caused by lack of buffering
      if ((position_union.bytes[0] == 0) || (position_union.bytes[0] == 0xFF))
      {
         position_union.bytes[0] = POSCNTL;
         position_union.bytes[1] = POSCNTH;
      }   
   
      lcd_gotoxy(1,1);
      printf(lcd_putc,"\fpos = %5lu",position_union.word);//%5lu\n\r, n is new line, r is carrier return
      printf("position = %5lu\n\r",position_union.word);
      printf("%5lu\n\r",position_union.word);
     // delay_us(20);
      lcd_gotoxy(2,2);
       c=bgetc(); // Here is the problem
      lcd_gotoxy(2,2);
      printf(lcd_putc,"%c",c); // LCD is empty
      delay_ms(200);
     // lcd_gotoxy(2,2);
      //printf(lcd_putc,"%d", Direction);
     // delay_ms(500);     
   }
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu May 17, 2012 12:49 pm     Reply with quote

Quote:
enable_interrupts (INT_IC2QEI);
enable_interrupts(int_rda);
enable_interrupts(GLOBAL);

I don't see an interrupt handler for the QEI interrrupt in your posted code.
Do you have one ?
ntrungtruc2003



Joined: 16 Feb 2011
Posts: 42

View user's profile Send private message

PostPosted: Fri May 18, 2012 1:05 am     Reply with quote

Following your guide I added an QEI_isr interrupt handler, and set priority for int_rda interrupt. Now, I can send and receive the value from Hyper Terminal but doesn't smoothly .

For example when I send ''1" from Hyper Terminal, the value of encoder is paused and "1" not display on lcd. Then I try to send "1" again, the value "1" is displayed on lcd and the value of encoder is normal.



Code:
#INT_IC2QEI
void qei_isr(){
flag = 1;
}

int_rda interrupt handler
Code:
#int_rda fast
void serial_isr() {

  d=getc();
  flag1 =1;
}


In main code
Code:

void main(void) {   
 
lcd_init();   
   
   QEICON =0b10110100;     //  11000  quad in x4 mode,INDX reset the position counters 
   DFLTCON = 0b00111011;      //110001 noise filter on QEA, QEB,, 1:2 clock
 
  enable_interrupts(int_rda);
  enable_interrupts (INT_IC2QEI);
  enable_interrupts(GLOBAL);
 
  while(TRUE)
   {
   
      position_union.bytes[0] = POSCNTL;
      position_union.bytes[1] = POSCNTH;
      // Workaround for hardware bug caused by lack of buffering
      if ((position_union.bytes[0] == 0) || (position_union.bytes[0] == 0xFF))
      {
         position_union.bytes[0] = POSCNTL;
         position_union.bytes[1] = POSCNTH;
      }   
   
      lcd_gotoxy(1,1);
      printf(lcd_putc,"\fpos = %5lu",position_union.word);//%5lu\n\r, n is new line, r is carrier return
      //printf("position = %5lu\n\r",position_union.word);
      printf("%5lu\n\r",position_union.word);
   
     
     while(flag1){
       d=getc(); // Here is the problem
       flag1 =0;
     }
     
       lcd_gotoxy(2,2);
       printf(lcd_putc,"%c",d); // THE VALUE DOES NOT SMOOTHLY.
   
      delay_ms(200);
   
   }
}
Ttelmah



Joined: 11 Mar 2010
Posts: 19496

View user's profile Send private message

PostPosted: Fri May 18, 2012 2:40 am     Reply with quote

First thing, I'd not be setting the INT_RDA as high priority. INT_RDA, has a long time in which it can be handled. The interrupt for the QEI doesn't. It is the QEI interrupt that should be high priority.
You do realise that UP/DOWN in QEICON, is a _read only_ bit. You try to set this to '1'.
Do you have an index signal connected?. You are enabling this to reset the QEI counter.
You don't appear to actually be needing/using the QEI interrupt at all - normal uses for this are to interrupt when a position 'match' occurs - you are not doing this, or when the index pulse is received, or when the counter wraps. If you are not using it, get rid of it...
I don't think your 'wrap' fix is correct. You are testing the low byte. Problem is that the low byte can perfectly legally be '0', if the counter is counting _downwards_, without a wrap having occurred. This would then give you a wrong value. Normally the fix is:
Code:

#word POSCNT=getenv("SFR:POSCNT")  // Position register
#byte POSCNTH=POSCNT+1  // Position register high byte


      do {
         position_union.word = POSCNT; //fastest possible 16bit transfer
      } while (POSCNTH!=position_union.bytes[1]); //retry if a wrap

This transfers the two bytes ASAP, then tests if the transferred 'high' byte matches the one still on the counter. If not, transfers again.
Also, as a general 'comment', change the serial interrupt handler to using the 'test if value equals buffer size' coding, rather than the '%' coding. A search here will find details. In your case the % coding is OK (because the buffer size is 32 bytes), but it is an 'accident waiting to happen'. It is unfortunate that CCS still use the % version in their example.... :(

Now, as written your 'bgetc', will lock the code, while it waits for a character to arrive. Normally you'd expect to keep looping, and doing other things, _till_ a character arrives. So, something like:
Code:

    do {
       //Main loop with code in
       
       //At some point:
       if (bkbhit()) {
          c= bgetc();
          //do what you want with the display etc.
       }
    }while (TRUE);


Best Wishes
ntrungtruc2003



Joined: 16 Feb 2011
Posts: 42

View user's profile Send private message

PostPosted: Fri May 18, 2012 11:44 pm     Reply with quote

With your help, I have successfully received value from Hyper Terminal and the value encoder is very good. Thank you so much.

Code:

#include <18F4431.h>

#use delay(clock=20000000)
#include <LCD_TM.c>
#use fast_io(a)       
#fuses HS,NOWDT,PUT,BROWNOUT,NOLVP,PWMPIN
#use rs232(baud=19200,parity=N,xmit=PIN_C6,rcv=PIN_C7,ERRORS)
//configuracoes QEI
// Definitions
#byte QEICON      = 0xFB6  // Quadrature Encoder Interface control register
#byte DFLTCON     = 0xF60  // Digital filter control register
//#byte POSCNTH     = 0xF67  // Position register high byte
//#byte POSCNTL     = 0xF66  // Position register low byte
//#BYTE CAP2BUFL=0xF66 // position counter
//#BYTE CAP2BUFH=0xF67
#BYTE CAP3BUFL=0xF64  //max count
#BYTE CAP3BUFH=0xF65
//#bit Direction  = 0xFB6.5
#define BUFFER_SIZE 32


BYTE buffer[BUFFER_SIZE];
BYTE next_in = 0;
BYTE next_out = 0;
char c;


union
{
   int8 bytes[2];
   int16 word;
} position_union;


#int_rda
void serial_isr() {
 
   int t;

   buffer[next_in]=getc();
   t=next_in;
   next_in=(next_in+1) % BUFFER_SIZE;
   if(next_in==next_out)
     next_in=t;           // Buffer full !!
}

#define bkbhit (next_in!=next_out)
char bgetc() {
   char c;

   while(!bkbhit) ;
   c=buffer[next_out];
   next_out=(next_out+1) % BUFFER_SIZE;
   return (c);
}


void main(void) {   
 char d;

lcd_init();   
   
   QEICON =0b10110100;     //  11000  quad in x4 mode,INDX reset the position counters 
   DFLTCON = 0b00111011;      //110001 noise filter on QEA, QEB,, 1:2 clock
 
  enable_interrupts(int_rda);
 // enable_interrupts (INT_IC2QEI);
  enable_interrupts(GLOBAL);
 do
   {
      if(POSCNTH!=position_union.bytes[1])
      {
         position_union.word = POSCNT; //fastest possible 16bit transfer
      } //retry if a wrap
     
      lcd_gotoxy(1,1);
      printf(lcd_putc,"\fpos = %5lu",position_union.word);//%5lu\n\r, n is new line, r is carrier return
      //printf("position = %5lu\n\r",position_union.word);
     printf("%5lu\n\r",position_union.word);
      lcd_gotoxy(2,2);
      if(bkbhit)
       {
          d=bgetc();       
       } 
    printf(lcd_putc,"%c",d);
   
    if(d=='1')
    {
    output_d(0x0f);
    }
    else
    {
    output_d(0xff);
    }
   
     delay_ms(50);
   }
   while(true);
}
Ttelmah



Joined: 11 Mar 2010
Posts: 19496

View user's profile Send private message

PostPosted: Sat May 19, 2012 2:14 am     Reply with quote

Put the version in as I posted it
What you have:
Code:

      if(POSCNTH!=position_union.bytes[1])
      {
         position_union.word = POSCNT; //fastest possible 16bit transfer
      } //retry if a

Is _not_ equivalent to:
Code:

       do {
         position_union.word = POSCNT; //fastest possible 16bit transfer
      } while (POSCNTH!=position_union.bytes[1]); //retry if a wrap

The 'do..while', tests _after_ the transfer. Your 'if' tests in front. Difference is that the read has not been performed at this point, so the byte value will be from the _last_ read. The do..while _always_ performs the transfer once. Your 'if' does not, meaning you will miss counter updates, if the high byte has not changed....

Glad it is working better. Smile

Best Wishes
ntrungtruc2003



Joined: 16 Feb 2011
Posts: 42

View user's profile Send private message

PostPosted: Mon May 21, 2012 8:42 am     Reply with quote

Following your guide. It runs better. Thanks you so much
When I connects 2 PIC18F4431 together by using I2c protocol (SDA is C4 pin and SCL is C5 pin), SSP_RC in #fuses, 4k7 ohm on 2 lines. It isn't successful.
For example: Oscilloscope can't detect any pulses on SDA and SCL. Slave pic18f4431 can't receive any thing from mater chip.

After that I tried to use D2(SDA) pin and D3 (SCL) alternate C2 and C3.
The oscilloscope display pulses but salve chip can not reveive data from master. I have also SSP_RD on #fuses.

Two boards tested successfully with PIC16F877A i2c.

Can you teach me again how to correct them.


Master
Code:

#include <18F4431.h>//master
#use delay(clock=20000000)
#include <LCD_TM.c>   
#fuses HS,NOWDT,PUT,BROWNOUT,NOLVP,SSP_RC
#use rs232(baud=19200,parity=N,xmit=PIN_C6,rcv=PIN_C7,ERRORS)

#define BUFFER_SIZE 32
#use i2c(MASTER, SDA=PIN_C4, SCL=PIN_C5)
#define READ_ADDRESS 0x61
#define WRITE_ADDRESS 0x60
BYTE buffer[BUFFER_SIZE];
BYTE next_in = 0;
BYTE next_out = 0;
char c;


#int_rda
void serial_isr() {
 
   int t;
   

   buffer[next_in]=getc();
   t=next_in;
   next_in=(next_in+1) % BUFFER_SIZE;
   if(next_in==next_out)
     next_in=t;           // Buffer full !!   
}

#define bkbhit (next_in!=next_out)
char bgetc() {
   char c;

   while(!bkbhit) ;
   c=buffer[next_out];
   next_out=(next_out+1) % BUFFER_SIZE;
   return (c);
   
}

void main(void) {   
 char d;

   lcd_init();   
  enable_interrupts(int_rda);
  enable_interrupts(GLOBAL);
 do
   {
     
     
      lcd_gotoxy(1,1);
     
      if(bkbhit)
       {
          d=bgetc();       
       } 
    printf(lcd_putc,"%c",d); // LCD is empty
   
    lcd_gotoxy(5,1);
     printf(lcd_putc,"Truc master"); // LCD is empty
    lcd_gotoxy(10,2);
    i2c_start();
    i2c_write(WRITE_ADDRESS);
    i2c_write(d);
    i2c_stop();
     printf(lcd_putc,"%02x",i2c_write(WRITE_ADDRESS));
    i2c_stop();
   
     delay_ms(100);
   }
   while(true);
}


Slave:
Code:

#include <18f4431.h>//slave
#use delay(clock=20000000)
#include <LCD_TM.c>   
#fuses HS,NOWDT,PUT,BROWNOUT,NOLVP,SSP_RC
#use rs232(baud=19200,parity=N,xmit=PIN_C6,rcv=PIN_C7,ERRORS)
#define BUFFER_SIZE 32
#use i2c(SLAVE, SDA=PIN_C4, SCL=PIN_C5, address=0x60)

BYTE address=0x00;
BYTE buffer1[0x10];
BYTE dummy;

#INT_SSP
void ssp_interupt ()
{
   BYTE incoming, state;

   state = i2c_isr_state();

   if(state < 0x80)                     //Master is sending data
   {
      incoming = i2c_read();
     
      if(state == 1)                     //First received byte is address
         address = incoming;
         
      if(state == 2)                     //Second received byte is data
         buffer1[address] = incoming;
           
   }
   if(state == 0x80)                     //Master is requesting data
   {
      dummy = i2c_read();
      i2c_write(buffer1[address]);
   }
}

BYTE buffer[BUFFER_SIZE];
BYTE next_in = 0;
BYTE next_out = 0;
char c;




#int_rda
void serial_isr() {
 
   int t;
   

   buffer[next_in]=getc();
   t=next_in;
   next_in=(next_in+1) % BUFFER_SIZE;
   if(next_in==next_out)
     next_in=t;           // Buffer full !!
     
}

#define bkbhit (next_in!=next_out)
char bgetc() {
   char c;

   while(!bkbhit) ;
   c=buffer[next_out];
   next_out=(next_out+1) % BUFFER_SIZE;
   return (c);
   
}


void main(void) {   
 char d;

lcd_init();   
   enable_interrupts(INT_SSP);
  enable_interrupts(int_rda);
  enable_interrupts(GLOBAL);
 do
   {
     
     
     
      lcd_gotoxy(2,2);
      if(bkbhit)
       {
          d=bgetc();       
       } 
    printf(lcd_putc,"%c",d); // LCD is empty
    if(d=='1'){
    output_d(0x0f);
    }
    else
    {
    output_d(0xff);
    }
    lcd_gotoxy(1,1);
    printf(lcd_putc,"Truc");
    lcd_gotoxy(1,2);
    printf(lcd_putc,"%02x",dummy);
    lcd_gotoxy(6,2);
    printf(lcd_putc,"%02x",address);
    lcd_gotoxy(14,2);
    printf(lcd_putc,"%02x",buffer1[address]);
     delay_ms(100);
   }
   while(true);
}
Ttelmah



Joined: 11 Mar 2010
Posts: 19496

View user's profile Send private message

PostPosted: Mon May 21, 2012 9:08 am     Reply with quote

This has been met before here.
Two parts to it:

CCS, tries to handle TRIS for you. It gets confused when the SPI is switched to alternate pins.

So, on the slave, change the #USE, to:
#use I2C(SLAVE, I2C1, address=0x60)

Which ensures it uses the hardware peripheral, and doesn't care what pins this is on. Set SSP_RC in the fuses, and then _manually_ set the TRIS bits on C4, and C5 (both to '1' for the slave).

On the master, you have to use software I2C. Select 'FORCE_SW', since the 4431, has an SSP module, _not_ an MSSP (lack of the 'M' means no master operation). So here your #USE, becomes:

#use i2c(MASTER, SDA=PIN_C4, SCL=PIN_C5, FORCE_SW), and the fuse doesn't matter.

The FORCE_SW is essential. Problem is the compiler 'sees' the peripheral as present, and doesn't know it is only 'half there'....

Unfortunately a 'downside' on these chips.

Best Wishes
ntrungtruc2003



Joined: 16 Feb 2011
Posts: 42

View user's profile Send private message

PostPosted: Tue May 22, 2012 2:37 pm     Reply with quote

Two 18f4431 master and slave have communicated after I decreased 4k7 ohm to 2k2 ohm. The values sent from master could be display on lcd of slave but didn't smoothly with d="4", d="3".

In the following code. Hyperterminal sends the d value variable to Master 18F4431. After that master send d and d+1 to slave 18F4431. Finally, slave display d and d+1 following hexa format.

With d=4, This function
Code:
printf(lcd_putc,"%02x",buffer1[address])
display 35, sometime 16. The value usually changes between 35 and 16.

With d=3, This function
Code:
printf(lcd_putc,"%02x",buffer1[address])
display 34, sometime 15. The value usually changes between 34 and 15.

After test d =1,2,5,6,7. The result is good, master displays right, salve display right.

master:
Code:
#include <18F4431.h>//master
#use delay(clock=20000000)
#include <LCD_TM.c>       
#fuses HS,NOWDT,PUT,BROWNOUT,NOLVP,PWMPIN,SSP_RC
#use rs232(baud=19200,parity=N,xmit=PIN_C6,rcv=PIN_C7,ERRORS)

#define BUFFER_SIZE 32
#use i2c(MASTER, SDA=PIN_C4, SCL=PIN_C5,FORCE_SW)
#define READ_ADDRESS 0x61
#define WRITE_ADDRESS 0x60
BYTE buffer[BUFFER_SIZE];
BYTE next_in = 0;
BYTE next_out = 0;
char c;

#int_rda
void serial_isr() {
 
   int t;
   

   buffer[next_in]=getc();
   t=next_in;
   next_in=(next_in+1) % BUFFER_SIZE;
   if(next_in==next_out)
     next_in=t;           // Buffer full !!
     
     
}

#define bkbhit (next_in!=next_out)
char bgetc() {
   char c;

   while(!bkbhit) ;
   c=buffer[next_out];
   next_out=(next_out+1) % BUFFER_SIZE;
   return (c);
}

void main(void) {   
 char d='0';

lcd_init();   
   
   //QEICON =0b10110100;     //  11000  quad in x4 mode,INDX reset the position counters 
   //DFLTCON = 0b00111011;      //110001 noise filter on QEA, QEB,, 1:2 clock
  //enable_interrupts(INT_SSP);
  enable_interrupts(int_rda);
 // enable_interrupts (INT_IC2QEI);
  enable_interrupts(GLOBAL);
 do
   {
 
      lcd_gotoxy(2,2);
      if(bkbhit)
       {
          d=bgetc();       
       } 
    printf(lcd_putc,"%c",d); // LCD is empty
   
    lcd_gotoxy(10,2);
    i2c_start();
    i2c_write(WRITE_ADDRESS);
    i2c_write(d);
    i2c_write(d+1);
     i2c_stop();
     
    printf(lcd_putc,"%02x",i2c_write(d));
 
     delay_ms(100);
   }
   while(true);
}


slave:
Code:

#include <18F4431.h>//slave
#use delay(clock=20000000)
#include <LCD_TM.c>
#use fast_io(a)       
#fuses HS,NOWDT,PUT,BROWNOUT,NOLVP,PWMPIN,SSP_RC
#use rs232(baud=19200,parity=N,xmit=PIN_C6,rcv=PIN_C7,ERRORS)

#define BUFFER_SIZE 32
#use i2c(SLAVE, SDA=PIN_C4, SCL=PIN_C5, address=0x60,FORCE_HW)
BYTE dummy=0x00;
BYTE address=0x00;
BYTE buffer1[0x10];
BYTE incoming, state;
#INT_SSP
void ssp_interupt ()
{

   state = i2c_isr_state();

   if(state < 0x80)                     //Master is sending data
   {
      incoming = i2c_read();
     
      if(state == 1)                     //First received byte is address
         address = incoming;
         
      if(state == 2)                     //Second received byte is data
         buffer1[address] = incoming;
           
   }
   if(state == 0x80)                     //Master is requesting data
   {
      dummy = i2c_read();
      i2c_write(buffer1[address]);
   }
}

BYTE buffer[BUFFER_SIZE];
BYTE next_in = 0;
BYTE next_out = 0;
char c;



#int_rda
void serial_isr() {
 
   int t;
   

   buffer[next_in]=getc();
   t=next_in;
   next_in=(next_in+1) % BUFFER_SIZE;
   if(next_in==next_out)
     next_in=t;           // Buffer full !!   
}

#define bkbhit (next_in!=next_out)
char bgetc() {
   char c;

   while(!bkbhit) ;
   c=buffer[next_out];
   next_out=(next_out+1) % BUFFER_SIZE;
   return (c);
   
}


void main(void) {   
 char d;
 buffer1=0x00;
lcd_init();   
   
  // QEICON =0b10110100;     //  11000  quad in x4 mode,INDX reset the position counters 
 //  DFLTCON = 0b00111011;      //110001 noise filter on QEA, QEB,, 1:2 clock
   enable_interrupts(INT_SSP);
  enable_interrupts(int_rda);
 // enable_interrupts (INT_IC2QEI);
  enable_interrupts(GLOBAL);
 do
   {
 
      lcd_gotoxy(2,2);
     
      if(bkbhit)
       {
          d=bgetc();       
       } 
    printf(lcd_putc,"%c",d); // LCD is empty
    if(d=='1'){
    output_d(0x0f);
    }
    else
    {
    output_d(0xff);
    }
    lcd_gotoxy(4,2);
    printf(lcd_putc,"%02x",incoming);
    lcd_gotoxy(7,2);
    printf(lcd_putc,"%02x",state);
    lcd_gotoxy(10,2);
    printf(lcd_putc,"%02x",address);// data receive here
    lcd_gotoxy(14,2);
    printf(lcd_putc,"%02x",buffer1[address]);//confused between 35/16    with d="4",34/15, d="3"
     delay_ms(100);
   }
   while(true);
}
Ttelmah



Joined: 11 Mar 2010
Posts: 19496

View user's profile Send private message

PostPosted: Tue May 22, 2012 3:22 pm     Reply with quote

The value needed for the pull-up resistors depends on the bus capacitance.
4K7, is normally 'OK' for two devices on the same board, with normal tracks, You can go as low as 2K with a 5v supply. 4K7, will fail if the bus capacitance goes over about 200pF at standard operating speed. You might want to think about what connection you are using, since this is a significant figure.

Best Wishes
ntrungtruc2003



Joined: 16 Feb 2011
Posts: 42

View user's profile Send private message

PostPosted: Tue May 22, 2012 9:47 pm     Reply with quote

Thanks for your support very much.

And finally can you teach me again how correct the following problem

From Hyperterminal d= 4. Slave displays d+ 1 by Printf(lcd_putc,"%02x",buffer1[address]) is 35 or 16. The value is not stability 35 but usually changes 35 or 16.


From Hyperterminal d= 3. Slave displays d+ 1 by Printf(lcd_putc,"%02x",buffer1[address]) is 34 or 15. The value is not stability 34 but usually changes 34 or 15.

5 is 35 in ascii
4 is 34 in ascii
15 is NACK ascii
16 is SYN ascii

With another value of d(except 3 or 4), Printf(lcd_putc,"%02x",buffer1[address]) is true
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group