This is my code to output pattern on __R30
; ********************************************
.global ausgabe
ausgabe:
ldi r18, 0 ; initial value
ldi r30, 0x10 ; debug
ldi r17, 0x00 ; debug
mov r13, r15 ; R15 contains start address, save in R13
mov r12, r14 ; R14 contains number of data points
naechster:
lbbo &r30, r15, 4, 1 ; (r15) = pattern
lbbo &r17, r15, 0, 2 ; (r17) = time to wait to output next pattern
warte:
sub r17, r17, 1 ; delay loop
qbne warte, r17, 0 ;
add r15, r15, 5 ; next element, update pointer
sub r14, r14, 1 ; number of remaining elements - 1
qbne naechster, r14, 0 ; was it the last one?
mov r15, r13 ; yes, load addess pointer with saved value
mov r14, r12 ; and load loop counter with saved number of elements
lbbo &r18, r16, 0, 1 ; load variable, if 0 run again, if != 0 exit
or r30, r30, (1<<4) ; debug, trigger signal for oscilloscope
qbeq naechster, r18, 0 ; as long handshake[0] = 0 is
jmp r3.w2 ; r3 contains return address
;*****************************************************************
The datastructure:
typedef struct Event Event_t;
struct Event
{
unsigned int time; // number of loops to the next event
unsigned char pattern; // Bit 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
// ------+---+---+---+----+---+----+---+
// | | | d |~z34|z34|~z12|z12|
// ------+---+---+---+----+---+----+---+
};
int main( int argc, char *argv[])
{
int i;
int j;
Event_t event_knoten[500];
...
....
ausgabe(pattern_liste.anzahl, &event_knoten[0].time, &handshake[0]) ; // asm to write pattern
// as long handshake[0} == 0
It works fine, only the delay time loop need better resolution, at the moment the time for only one loop is too long.
Have no idea to optimize ist.
Also from
or r30, r30, (1<<4) ; debug, trigger signal for oscilloscope
to
naechster:
lbbo &r30, r15, 4, 1 ; (r15) = pattern
I measure 250nsec ..... was expecting 25nsec .....
I can see some jitter on my oscilloscope ( Tektronix THS730A ), has nothing to do with
GND connection, long wires etc., all that is perfect. Oscilloscope works fine.
Is it possible that "some what" from Linux / ARM area is disturbing my timing?
Thanks again for any helpfull input.
Kasimir