RE: [bascom] BASCOM-AVR Buffered Serial Problems (repeat)


From "Len Gabrielson" <lgabrielson@point360.net>
Date Tue, 10 Jul 2001 16:26:10 -0700

** High Priority **

Hi Mark,

I'm getting desperate.  I know what code I am supposed to get, but it's
not working, and Im running out of time.  
As you pointed out, I need to use the software uart because I need:

38400 baud
1Start bit
8 data bits
1 stop bit
odd parity

I am testing the incoming data with this:

$regfile = "8515def.dat"
$crystal = 4915200
'$baud = 38400

Ddrd = &B01111111
Ddra = &B11111111

Config Lcdpin = Pin , Db4 = Portc.4 , Db5 = Portc.5 , Db6 = Portc.6 ,
Db7 = Portc.7 , E = Portc.3 , Rs = Portc.2
Config Lcd = 16 * 2

Dim Status As String * 10
Dim A(20) As Byte
Dim B As Byte
Dim X As Word

Open "comd.0:38400,8,O,1" For Input As #1

Sb1:

    Status = Waitkey(#1)
    X = Hexval(status)
    If X = 118 Then                                         'look for
118D or 76H
       Lcd X ; " ";

   Status = Waitkey(#1)
       X = Hexval(status)                                   'should be
32D or 20H
       Lcd X ; " ";

   Status = Waitkey(#1)                                     'first byte
of interest
       X = Hexval(status)
       Lcd X ; " ";

   Status = Waitkey(#1)
       X = Hexval(status)                                   'second byte
of interst
       Lcd X ; " ";

   Status = Waitkey(#1)
       X = Hexval(status)
       Lcd X ; " ";
       Wait 2
       Cls : Home
   End If

       Goto Sb1

If you see a newbie blunder, please point it out.  My next posting will
be under the heading of NEED CODE--WILL PAY.

Thanks,
Len G.




>>> mark@mcselec.com 07/11/01 12:32AM >>>
Hi,

The serial buffered input/output is inteded for the hardware uart.
When you use INPUT,INKEY or WAITKEY you are doing serial input.
Normally this returns info from the serial port. But what happens if you
are
in an interrupt or performing a time consuming function? The hardware
uart
can only store 1 byte. So that is why  I wrote the buffered routines.
The
buffered input routine will store the incoming data in the buffer. Then
when
you use INPUT,WAITKEY etc., this data is pulled out of the serial
buffer.

The variables mentioned in the sample are only there for completeness.

When you want to check the serial input stream try this:
-1- open the channel
-2- perform some tests if you can receive data with a terminal emulator
for
example
-3- when all is working:
dim b as byte,v1 as byte,v2 as byte
do
  b = waitkey() ' get a byte from the serial input
  if b = &H20 then ' for example value of first byte
     b=waitkey() ' get next
     if b = &H78 then  ' vaue of next byte
        ' when you get here it means you can get the next 2 bytes
        v1 = waitkey() : v2 = waitkey()    ' get the values
        gosub dosomething
     end if
  end if
loop

dosomething:
' do an action here
return


Best regards,
Mark Alberts
-----Original Message-----
From: owner-bascom@grote.net [mailto:owner-bascom@grote.net]On Behalf Of
Len Gabrielson
Sent: dinsdag 10 juli 2001 9:13
To: bascom@grote.net
Subject: [bascom] BASCOM-AVR Buffered Serial Problems (repeat)


Hi again folks,

I don't know what happened to that last message, but it came back to me
is some weird format, so I'll try again...


I'm sorry, but either I better go back to STAMPs or I need some further
explaination.

Near the bottom of the RS232BUFFER.BAS sample it tells you some
variables that are used in the routine.  It also says that you won't
lose characters, IF YOU EMPTY THE BUFFER, but THE EXAMPLE DOESN'T TELL
YOU HOW TO DO THAT!

I am monitoring the _WPOINTER and _WCOUNTER bytes, and they always show
me a "0", even though there is data coming in.  Is there a variable that
represents the buffer itself, so that I can go in and look for the
byte/s I need?

Signed,
very confused.

>From the RS232BUFFER.BAS sample:

This time the chars are received by an interrupt routine and are
'stored in a buffer. This way you will not loose characters providing
that
'you empty the buffer
'So when you fast type abcdefg, they will be printed after each other
with the
'1 second delay

'Using the CONFIG SERIAL=BUFFERED, SIZE = 10 for example will
'use some SRAM memory
'The following internal variables will be generated :
'_WPOINTER   BYTE , a pointer to the location of the buffer that was
written last
'_RPOINTER   BYTE , a pointer to the location of the buffer that was
read last
'_WCOUNTER   BYTE , a counter that holds the number of chars in the
buffer
'calling _recChar0 will decrease this var , when a char is received it
will be increased
'_RS232INBUF STRING , the actual buffer with the size of SIZEb
Hi Mark,
 
I'm getting desperate.  I know what code I am supposed to get, but it's not working, and Im running out of time. 
As you pointed out, I need to use the software uart because I need:
 
38400 baud
1Start bit
8 data bits
1 stop bit
odd parity
 
I am testing the incoming data with this:
 
$regfile = "8515def.dat"
$crystal = 4915200
'$baud = 38400
 
Ddrd = &B01111111
Ddra = &B11111111
 
Config Lcdpin = Pin , Db4 = Portc.4 , Db5 = Portc.5 , Db6 = Portc.6 , Db7 = Portc.7 , E = Portc.3 , Rs = Portc.2
Config Lcd = 16 * 2
 
Dim Status As String * 10
Dim A(20) As Byte
Dim B As Byte
Dim X As Word
 
Open "comd.0:38400,8,O,1" For Input As #1

Sb1:
 
    Status = Waitkey(#1)
    X = Hexval(status)
    If X = 118 Then                                         'look for 118D or 76H
       Lcd X ; " ";
 
   Status = Waitkey(#1)
       X = Hexval(status)                                   'should be 32D or 20H
       Lcd X ; " ";
 
   Status = Waitkey(#1)                                     'first byte of interest
       X = Hexval(status)
       Lcd X ; " ";
 
   Status = Waitkey(#1)
       X = Hexval(status)                                   'second byte of interst
       Lcd X ; " ";
 
   Status = Waitkey(#1)
       X = Hexval(status)
       Lcd X ; " ";
       Wait 2
       Cls : Home
   End If
 
       Goto Sb1
 
If you see a newbie blunder, please point it out.  My next posting will be under the heading of NEED CODE--WILL PAY.
 
Thanks,
Len G.
 
 


>>> mark@mcselec.com 07/11/01 12:32AM >>>
Hi,

The serial buffered input/output is inteded for the hardware uart.
When you use INPUT,INKEY or WAITKEY you are doing serial input.
Normally this returns info from the serial port. But what happens if you are
in an interrupt or performing a time consuming function? The hardware uart
can only store 1 byte. So that is why  I wrote the buffered routines. The
buffered input routine will store the incoming data in the buffer. Then when
you use INPUT,WAITKEY etc., this data is pulled out of the serial buffer.

The variables mentioned in the sample are only there for completeness.

When you want to check the serial input stream try this:
-1- open the channel
-2- perform some tests if you can receive data with a terminal emulator for
example
-3- when all is working:
dim b as byte,v1 as byte,v2 as byte
do
  b = waitkey() ' get a byte from the serial input
  if b = &H20 then ' for example value of first byte
     b=waitkey() ' get next
     if b = &H78 then  ' vaue of next byte
        ' when you get here it means you can get the next 2 bytes
        v1 = waitkey() : v2 = waitkey()    ' get the values
        gosub dosomething
     end if
  end if
loop

dosomething:
' do an action here
return


Best regards,
Mark Alberts
-----Original Message-----
From: owner-bascom@grote.net [mailto:owner-bascom@grote.net]On Behalf Of
Len Gabrielson
Sent: dinsdag 10 juli 2001 9:13
To: bascom@grote.net
Subject: [bascom] BASCOM-AVR Buffered Serial Problems (repeat)


Hi again folks,

I don't know what happened to that last message, but it came back to me
is some weird format, so I'll try again...


I'm sorry, but either I better go back to STAMPs or I need some further
explaination.

Near the bottom of the RS232BUFFER.BAS sample it tells you some
variables that are used in the routine.  It also says that you won't
lose characters, IF YOU EMPTY THE BUFFER, but THE EXAMPLE DOESN'T TELL
YOU HOW TO DO THAT!

I am monitoring the _WPOINTER and _WCOUNTER bytes, and they always show
me a "0", even though there is data coming in.  Is there a variable that
represents the buffer itself, so that I can go in and look for the
byte/s I need?

Signed,
very confused.

>From the RS232BUFFER.BAS sample:

This time the chars are received by an interrupt routine and are
'stored in a buffer. This way you will not loose characters providing
that
'you empty the buffer
'So when you fast type abcdefg, they will be printed after each other
with the
'1 second delay

'Using the CONFIG SERIAL=BUFFERED, SIZE = 10 for example will
'use some SRAM memory
'The following internal variables will be generated :
'_WPOINTER   BYTE , a pointer to the location of the buffer that was
written last
'_RPOINTER   BYTE , a pointer to the location of the buffer that was
read last
'_WCOUNTER   BYTE , a counter that holds the number of chars in the
buffer
'calling _recChar0 will decrease this var , when a char is received it
will be increased
'_RS232INBUF STRING , the actual buffer with the size of SIZEb