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

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

RE: [avr-gcc-list] Software UART receiver first byte as NULL / empty


From: harshit suri
Subject: RE: [avr-gcc-list] Software UART receiver first byte as NULL / empty
Date: Fri, 12 Mar 2004 11:47:03 -0800 (PST)

Thanks for ure reply. I am posting the basic stamp
code as u asked. I have also tried doing 
serout 6,16468,["HowdyAtmega01234"] .It yield the same
problem. Any help will be aprreciated


'{$STAMP BS2}

'this code implements the commn protocol
'it tries to communicate with the atmega128

rx con 5 'receive from atmega
tx con 6  'transmit to atmega
input 5
output 6
looper:
'make my tx high to indicate to atmega128 that i am
ready to send
high 6


'wait for atmega128 to acknowledge
wait_for_ack:
if IN5 = 1 then sendbyte 'that means atmega shall give
the stamp a chance to communicate.This DOES NOT mean
that he has set up his uart
goto wait_for_ack

sendbyte:
low 6 'lower the tx line telling mega that ill send
data whenever atmega is ready

wait_till_atmega_has_setup_UART:
if IN5=0 then senddata 'wait for atmega128 to lower
its txline that means that atmega has set up his uart
and is ready to receive
goto wait_till_atmega_has_setup_UART

senddata:
serout 6,16468,["H"] 'send data at 9600baud 8N1
inverted LSB first
serout 6,16468,["o"] 'send data at 9600baud 8N1
inverted LSB first
serout 6,16468,["w"] 'send data at 9600baud 8N1
inverted LSB first
serout 6,16468,["d"] 'send data at 9600baud 8N1
inverted LSB first
serout 6,16468,["y"] 'send data at 9600baud 8N1
inverted LSB first
serout 6,16468,["A"] 'send data at 9600baud 8N1
inverted LSB first
serout 6,16468,["t"] 'send data at 9600baud 8N1
inverted LSB first
serout 6,16468,["m"] 'send data at 9600baud 8N1
inverted LSB first
serout 6,16468,["e"] 'send data at 9600baud 8N1
inverted LSB first
serout 6,16468,["g"] 'send data at 9600baud 8N1
inverted LSB first
serout 6,16468,["a"] 'send data at 9600baud 8N1
inverted LSB first
serout 6,16468,["0"] 'send data at 9600baud 8N1
inverted LSB first
serout 6,16468,["1"] 'send data at 9600baud 8N1
inverted LSB first
serout 6,16468,["2"] 'send data at 9600baud 8N1
inverted LSB first
serout 6,16468,["3"] 'send data at 9600baud 8N1
inverted LSB first
serout 6,16468,["4"] 'send data at 9600baud 8N1
inverted LSB first
'right now atmega is printing out what it recvd to the
debug terminal
goto looper 'do whole step again...this makes sure
experiment is repeatable and error free



--- "D. Daniel McGlothin" <address@hidden> wrote:
> I'm curious about the exact Basic Stamp commands
> that you are using to
> send the data to the AVR.  Could you post the
> relevant portion of the
> Stamp's program?
> 
> Daniel
> 
> > -----Original Message-----
> > From: address@hidden
> > [mailto:address@hidden Behalf Of
> harshit suri
> > Sent: Friday, March 12, 2004 12:55 PM
> > To: address@hidden
> > Subject: RE: [avr-gcc-list] Software UART receiver
> first
> > byte as NULL /
> > empty
> >
> >
> > i was thinking the same ..that the handshaking
> might
> > be triggering a start bit ISR. *But* the waveform
> at
> > the RX pin of the atmega128 is absolutely clear no
> > spurious noise bits.The devices dont need level
> > converters both are 0-5V . And as i said if i
> remove
> > the handshaking and all i do is listen in the mega
> and
> > tx from stamp continousule. then all is fine.
> Thanks
> > for ure reply.
> > Regards
> >
> > --- Rune Christensen
> <address@hidden>
> > wrote:
> > > Hello
> > >
> > > If the handshaking uses the rx and tx signals
> maybe
> > > it will trigger a false
> > > start bit.
> > > Normally handshaking uses other dedicated pins
> for
> > > that purpose.
> > >
> > > If you don't have enough pins then maybe
> consider
> > > software handshaking
> > > instead of hardware handshaking.
> > >
> > > Have you voltage level conversion between the
> two
> > > devices?
> > >
> > > Cheers
> > > Rune Christensen
> > >
> > > -----Original Message-----
> > > From: address@hidden
> > > [mailto:address@hidden Behalf
> Of
> > > harshit suri
> > > Sent: Friday, March 12, 2004 10:21 AM
> > > To: address@hidden
> > > Subject: [avr-gcc-list] Software UART receiver
> first
> > > byte as NULL /
> > > empty
> > >
> > >
> > > I am using the Software Uart Code from
> > > http://hubbard.engr.scu.edu/embedded/avr/avrlib/
> . I
> > > am using a basic stamp to send data to the
> > > atmega128.
> > > I uses a handshaking protocol to communicate.
> The
> > > stamp sends 16 bytes
> > > "HowdyAtmega01234"
> > > and the software uart(its interrupt based)
> listens
> > > for
> > > 16 bytes at once.
> > >
> > > The problem is that the atmega reads a NULL byte
> > > first
> > > before reading the 'H' in Howdy . So when i
> print it
> > > out it prints:
> > >
> > > Byte[0] =
> > > Byte[1] =H
> > > Byte[2] = o
> > > Byte[3] = w
> > > Byte[4] = d
> > > Byte[5] = y
> > > Byte[6] = A
> > > Byte[7] = t
> > > Byte[8] = m
> > > Byte[9] = e
> > > Byte[10] = g
> > > Byte[11] = a
> > > Byte[12] = 0
> > > Byte[13] = 1
> > > Byte[14] = 2
> > > Byte[15] = 3
> > >
> > > If i increase the buffer length to 17 it
> recieves
> > > the
> > > character '4' too. But somehow it always manages
> to
> > > receive a blank character. I thouroughly checked
> the
> > > waveform by back annotating the compelete
> waveform .
> > > its perfect. Also i checked if there was any
> spike
> > > coming before the letter 'H'(the spike could
> have
> > > triggered the start bit ISR) but No... the line
> was
> > > not noisy and was maintaining Low.
> > > I tried a version in which no handshaking was
> taking
> > > place and the stamp was continously sending the
> > > string
> > > and the atmega was listening it was Ok. no blank
> > > characters. I have no idea what to test now. The
> > > uartsw receive bit interrupt routine is
> activated
> > > only
> > > after the handhaking is completed. and the
> waveform
> > > is
> > > clean.
> > >
> > > here is the code. Should i post the complete
> code if
> > > needed?
> > >
> > > heres main loop:
> > > while(1)
> > > {
> > > while(!(inb(PIND) & (1<<UartswRxPin))); //wait
> for
> > > stamp to ask for a request to send
> > > //acknowledge the stamp
> > > sbi(PORTD,UartswTxPin);
> > > while(inb(PIND) & (1<<UartswRxPin)); //wait for
> > > stamp
> > > to say that its going to send data in a while
> > > //get ure receiver ready
> > > uartswInitRx();
> > > temp = uartswGetRxBuffer();
> > > // tell the stamp ure UART has been set up to
> > > receive
> > > and the stamp should send
> > > cbi(PORTD,UartswTxPin);
> > > while((temp->datalength) <
> UARTSW_RX_BUFFER_SIZE);
> > > //wait till 16 bytes are recieved
> > > uartswOff();
> > > i = 0;
> > > while(i < UARTSW_RX_BUFFER_SIZE) //print out the
> 16
> > > bytes. Print to the PC host using hardware UART
> at
> > > 9600 8N1
> > > {
> > > printf("Byte[%u] =
> > > %c\n\r",i,bufferGetAtIndex(temp,i));
> > > i++;
> > > }
> > >
> > > }
> > >
> > > __________________________________
> > > Do you Yahoo!?
> > > Yahoo! Search - Find what youre looking for
> faster
> > > http://search.yahoo.com
> > >
> > > _______________________________________________
> > > avr-gcc-list mailing list
> > > address@hidden
> > >
> http://www.avr1.org/mailman/listinfo/avr-gcc-list
> > >
> >
> >
> > __________________________________
> > Do you Yahoo!?
> > Yahoo! Search - Find what youre looking for
> faster
> > http://search.yahoo.com
> >
> > _______________________________________________
> > avr-gcc-list mailing list
> > address@hidden
> > http://www.avr1.org/mailman/listinfo/avr-gcc-list
> >
> >
> 
> 


__________________________________
Do you Yahoo!?
Yahoo! Search - Find what you’re looking for faster
http://search.yahoo.com

_______________________________________________
avr-gcc-list mailing list
address@hidden
http://www.avr1.org/mailman/listinfo/avr-gcc-list


reply via email to

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