avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-gcc-list] Speed challenge...


From: Rob Ward
Subject: [avr-gcc-list] Speed challenge...
Date: Fri, 26 Apr 2002 14:32:01 +1200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:0.9.9) Gecko/20020311

Hi. I have a challenge. The (working) code below outputs 19 bits serially from a 4433 uC to another chip using data, clock, and strobe lines. The data comes from 3 lookup arrays of 256 bytes each. At 4MHz on a 4433 uC , it takes about 87us to send all 19 bits. I wonder if there is a faster way of doing the job?

Rob

///////////////////////////////////////////////////////////////////
// send 19 configuration bits
///////////////////////////////////////////////////////////////////
void Send_Word(u08 Step_Pos) {
 u08 mask, data, i;

 mask = 0x80;
 data = PRG_RDB(&Word_Hi[Step_Pos]);

__cbi(PORTD,6); // set strobe low to initiate data transfer

 for (i=0; i<=7; i++) {                // send first 8 bits

   __cbi(PORTD,5);                     // set clock line low

   if (mask & data)                    // present data
     __sbi(PORTD,4);
   else
     __cbi(PORTD,4);

   __sbi(PORTD,5);                     // clock the data bit

   mask >>= 1;
 }

 mask = 0x80;
 data = PRG_RDB(&Word_Mid[Step_Pos]);

 for (i=0; i<=7; i++) {                // send first 8 bits

   __cbi(PORTD,5);                     // set clock line low

   if (mask & data)                    // present data
     __sbi(PORTD,4);
   else
     __cbi(PORTD,4);

   __sbi(PORTD,5);                     // clock the data bit

   mask >>= 1;
 }

 mask = 0x80;
 data = PRG_RDB(&Word_Lo[Step_Pos]);

 for (i=0; i<=2; i++) {                // send first 8 bits

   __cbi(PORTD,5);                     // set clock line low

   if (mask & data)                    // present data
     __sbi(PORTD,4);
   else
     __cbi(PORTD,4);

   __sbi(PORTD,5);                     // clock the data bit

   mask >>= 1;
 }

__sbi(PORTD,6); // reset strobe to high to terminate data transfer } // End Send_Word() // (don't care what state the data line holds upone exiting here)




avr-gcc-list at http://avr1.org



reply via email to

[Prev in Thread] Current Thread [Next in Thread]