You are hereBitscope ! AVR! awesome! /
Bitscope ! AVR! awesome!
Well I got my bitscope USB oscilloscope, thanks jeff! this is a truly great tool.
Finally I can see what is going on with my STK500 Atmel ATMEGA32 based embedded chipset ports :) makes it a lot easier as i'm working towards getting my own EFI software up and running to power - most likely either my 4.3lt or 5.3lt chrysler, but either way, it's a lot of fun to toy with, and theres a billion uses for an oscilloscope.
So basically what i'm doing is compiled on my linux machine with avr-gcc and uploading that binary to the atmega32 via serial port (usb converter ttyUSB1)
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/signal.h>
#define F_OSC 3680000
short f;
SIGNAL(SIG_OVERFLOW1)
{
if(f==0) {
DDRB=0xff;
f=1;
} else {
DDRB=0x0a;
f=0;
}
TCNT1=60911; // reset counter to .1 mS
}
// Start timer running
void startsubtimer(void)
{
TCCR1B=1;
TCNT1=60740;
TIFR&=~(1<<TOV1);
TIMSK|=(1<<TOIE1); // start timer
timeron=1;
}
void starttimer(void)
{
subtick=10;
startsubtimer();
}
// Stops the timer
void stoptimer(void)
{
timeron=0;
TIMSK&=~(1<<TOIE1); // stop interrupts
TCCR1B=0; // halt timer
}
int main(void)
{
sei(); // enable interrupts (req'd for timer)
DDRB=1; // LED on PORTB.0 is an output
DDRB = 0x0A;
startsubtimer();
f =0;
while (1)
{
}
return 0; // not reached
}
I keep this in a Makefile to "make" it easier :)
CC=avr-gcc
CFLAGS=-g -Os -Wall -mcall-prologues -mmcu=atmega32
OBJ2HEX=avr-objcopy
UISP=uisp
TARGET=sio
program : $(TARGET).hex
$(UISP) -dprog=stk500 -dserial=/dev/ttyUSB1 --erase -dpart=atmega32
$(UISP) -dprog=stk500 -dserial=/dev/ttyUSB1 --upload -dpart=atmega32 \
if=$(TARGET).hex -v=2
%.obj : %.o
$(CC) $(CFLAGS) $< -o $@
%.hex : %.obj
$(OBJ2HEX) -R .eeprom -O ihex $< $@
clean :
rm -f *.hex *.obj *.o
Basically so far this is just a test, but it should be flipping a port (a pin on the cpu)'s status every clock tick (kind of, theres a couple of instructions that are delaying the timing)

with the logic probes on the POD activated you can see one line (blue) following the analogue reading, the time division is set at 10us and im getting just over 2 flips of a state every division so im guessing the flip is happening every 4us ? but i cant figure out how to find out *exactly* what this time is, surely theres some measurement tool in the bitscope DSO for this ? i am a newb!

Click here for a screen shot of the complete software
Which leaves my desk looking like this

Bitscope BS50U on the left, Atmel STK500+ATmega32 in the middle, and my laptop on the right showing the output as pictured above
