[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] AVR assembly for fast bit bang
From: |
Nils Springob |
Subject: |
Re: [avr-gcc-list] AVR assembly for fast bit bang |
Date: |
Wed, 09 Nov 2005 16:29:48 +0100 |
User-agent: |
Mozilla Thunderbird 1.0.6 (Windows/20050716) |
Hi,
I think there are two problems with the code:
- using 16 bit data
- shifting by a variable number of bits
An optimization would be to write a funktion which only shifts up to 8
bit, and to shift the data every time by one bit.
Regards,
Nils
original code:
void write_data (Word towrite, Byte nbits)
{
Byte n;
for(n = 0; n < nbits; n++)
{
CLK_HIGH;
if( towrite & (0x0001 << n))
{
SDIO_HIGH;
}
else
{
SDIO_LOW;
}
CLK_LOW;
}
}
my version:
void write_data_byte (Byte towrite, Byte nbits)
{
while(nbits--)
{
CLK_HIGH;
if (towrite&0x01)
{
SDIO_HIGH;
}
else
{
SDIO_LOW;
}
CLK_LOW;
towrite = towrite>>1; // shift by constant value
}
}
void write_data (Word towrite, Byte nbits)
{
if (nbits>8)
{
write_data_byte((Byte)towrite, 8);
write_data_byte((Byte)(towrite>>8), nbits-8);
}
else
{
write_data_byte((Byte)towrite, nbits);
}
}
- [avr-gcc-list] AVR assembly for fast bit bang, Mike S., 2005/11/08
- Re: [avr-gcc-list] AVR assembly for fast bit bang, Hugo González Monteverde, 2005/11/08
- Re: [avr-gcc-list] AVR assembly for fast bit bang, Daniel O'Connor, 2005/11/08
- Re: [avr-gcc-list] AVR assembly for fast bit bang, David Kelly, 2005/11/08
- Re: [avr-gcc-list] AVR assembly for fast bit bang, Mike S., 2005/11/09
- Re: [avr-gcc-list] AVR assembly for fast bit bang, Daniel O'Connor, 2005/11/09
- Re: [avr-gcc-list] AVR assembly for fast bit bang, Peter Fuhrmann, 2005/11/09
- Re: [avr-gcc-list] AVR assembly for fast bit bang, Jesper Hansen, 2005/11/09
- Re: [avr-gcc-list] AVR assembly for fast bit bang,
Nils Springob <=
- Re: [avr-gcc-list] AVR assembly for fast bit bang, David Brown, 2005/11/10
- Re: [avr-gcc-list] AVR assembly for fast bit bang, Mike S., 2005/11/16
- Re: [avr-gcc-list] AVR assembly for fast bit bang, Dave Hansen, 2005/11/09