[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] Speed challenge...
From: |
Andreas Schwarz |
Subject: |
Re: [avr-gcc-list] Speed challenge... |
Date: |
Fri, 26 Apr 2002 12:19:32 +0200 |
Hi Rob,
Friday, April 26, 2002, 4:32:01 AM, you wrote:
> 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?
you could do it in assembler. I have attached a function I wrote for a
SPI interface, perhaps this will help you.
/*
Funktion für Software-SPI
Sendet ein Datenbyte an einen an Port B angeschlossenen 74HC595
void spi(unsigned char);
*/
#include <macros.inc>
#include <ctoasm.inc>
#define value rP1
/*
Welche Pins sollen für die einzelnen SPI-Leitungen verwendet werden?
*/
#define MOSI 0
#define SCK 2
#define count rTI0
.global spi
.func spi
spi:
clr count
loop:
cbi PORTB, MOSI
rol value
brcc carrycleared
sbi PORTB, MOSI
carrycleared:
nop
sbi PORTB, SCK
nop
cbi PORTB, SCK
inc count
cpi count, 8
brne loop
ret
.endfunc
avr-gcc-list at http://avr1.org