time of getchar
2011-07-07 by Ahmed Mostafa
Yahoo Groups archive
Index last updated: 2026-04-28 22:41 UTC
Thread
2011-07-07 by Ahmed Mostafa
command "getchar()" if it didn't receive serial data does it skips this command or what and if it skips it , how long does it take since this command "getchar()" is executed until it skips it ?
2011-07-07 by ho hoh
به نام خدا سلام اگه فارسی داشته باش : اگر با کدویژن برنامه می نویسی و از کد ویزارد استفاده می کنی از این تابع خارج نمیشوی , مگر اینکه دیتایی دریافت کنی , حتی اگر از وقفه استفاده کرده باشی . ولی چنانچه بخواهی این مشکل را برطرف کنی باید خودت دست به کار شوی و به کمک دیتا شیت و با توجه به کارت از این تابع رد شوی یا اینکه مدتی صبر کنی اگر دیتایی نیامد بعد از تابع خارج شوی. بخش پورت سریال دیتاشیت میکروکنترلرت را به طور کامل و به دقت بخوان خیلی کمکت می کند . کلیه نوت ها رو هم بخوان . ________________________________
From: Ahmed Mostafa <justforstudy2011@gmail.com> To: AVR-Chat@yahoogroups.com Sent: Thursday, July 7, 2011 23:09:59 Subject: [AVR-Chat] time of getchar command "getchar()" if it didn't receive serial data does it skips this command or what and if it skips it , how long does it take since this command "getchar()" is executed until it skips it ? [Non-text portions of this message have been removed]
2011-07-07 by Ahmed Mostafa
can you write in English please ?
On 7/7/11, ho hoh <hop_hoh@yahoo.com> wrote: > به نام خدا > سلام > اگه فارسی داشته باش : > اگر با کدویژن برنامه می نویسی و از کد ویزارد استفاده می کنی از این تابع خارج > نمیشوی , مگر اینکه دیتایی دریافت کنی , حتی اگر از وقفه استفاده کرده باشی . > ولی چنانچه بخواهی این مشکل را برطرف کنی باید خودت دست به کار شوی و به کمک > دیتا > شیت و با توجه به کارت از این تابع رد شوی یا اینکه مدتی صبر کنی اگر دیتایی > نیامد > بعد از تابع خارج شوی. > بخش پورت سریال دیتاشیت میکروکنترلرت را به طور کامل و به دقت بخوان خیلی کمکت > می > کند . کلیه نوت ها رو هم بخوان . > > > > ________________________________ > From: Ahmed Mostafa <justforstudy2011@gmail.com> > To: AVR-Chat@yahoogroups.com > Sent: Thursday, July 7, 2011 23:09:59 > Subject: [AVR-Chat] time of getchar > > > command "getchar()" > if it didn't receive serial data > does it skips this command or what > and if it skips it , how long does it take > since this command "getchar()" is executed until it skips it ? > > > > > [Non-text portions of this message have been removed] > >
2011-07-08 by Dave McLaughlin
Hi there,
I am assuming you are using an interrupt driven serial port here? Best
option by the way as it gets filled under interrupts so less likely to lose
data. The following applies if this is turned on.
You need to check the variable rx_counter0 (check your code for the correct
name) before calling getchar()
If this is non-zero it indicates there is data in the buffer.
if(rx_counter0)
{
ch = getchar();
}
You can actually check this for a certain value if you happen to know the
length of the data otherwise, you have to deal with variable length input.
Hope this helps?
Dave.From: AVR-Chat@yahoogroups.com [mailto:AVR-Chat@yahoogroups.com] On Behalf Of Ahmed Mostafa Sent: 08 July 2011 01:40 To: AVR-Chat@yahoogroups.com Subject: [AVR-Chat] time of getchar command "getchar()" if it didn't receive serial data does it skips this command or what and if it skips it , how long does it take since this command "getchar()" is executed until it skips it ? [Non-text portions of this message have been removed]
2011-07-08 by Ahmed Mostafa
thanks for your help
actually i don't use interrupt
and if it didn't receive data , i want it to skip the getchar command
so can i use
if(getchar()) //instead of if(rx_counter0)
{
ch = getchar();
}On 7/8/11, Dave McLaughlin <dave_mclaughlin@nerdshack.com> wrote:
> Hi there,
>
>
>
> I am assuming you are using an interrupt driven serial port here? Best
> option by the way as it gets filled under interrupts so less likely to lose
> data. The following applies if this is turned on.
>
>
>
> You need to check the variable rx_counter0 (check your code for the correct
> name) before calling getchar()
>
>
>
> If this is non-zero it indicates there is data in the buffer.
>
>
>
> if(rx_counter0)
>
> {
>
> ch = getchar();
>
> }
>
>
>
> You can actually check this for a certain value if you happen to know the
> length of the data otherwise, you have to deal with variable length input.
>
>
>
> Hope this helps?
>
> Dave.
>
>
>
> From: AVR-Chat@yahoogroups.com [mailto:AVR-Chat@yahoogroups.com] On Behalf
> Of Ahmed Mostafa
> Sent: 08 July 2011 01:40
> To: AVR-Chat@yahoogroups.com
> Subject: [AVR-Chat] time of getchar
>
>
>
>
>
> command "getchar()"
> if it didn't receive serial data
> does it skips this command or what
> and if it skips it , how long does it take
> since this command "getchar()" is executed until it skips it ?
>
>
>
>
>
> [Non-text portions of this message have been removed]
>
>2011-07-08 by Ahmed Mostafa
and if i use interrupt pleause clarify to me how to define variable rx_counter0 in the interrupt routine
On 7/8/11, Ahmed Mostafa <justforstudy2011@gmail.com> wrote:
> thanks for your help
> actually i don't use interrupt
> and if it didn't receive data , i want it to skip the getchar command
> so can i use
>
> if(getchar()) //instead of if(rx_counter0)
> {
> ch = getchar();
> }
>
>
> On 7/8/11, Dave McLaughlin <dave_mclaughlin@nerdshack.com> wrote:
>> Hi there,
>>
>>
>>
>> I am assuming you are using an interrupt driven serial port here? Best
>> option by the way as it gets filled under interrupts so less likely to
>> lose
>> data. The following applies if this is turned on.
>>
>>
>>
>> You need to check the variable rx_counter0 (check your code for the
>> correct
>> name) before calling getchar()
>>
>>
>>
>> If this is non-zero it indicates there is data in the buffer.
>>
>>
>>
>> if(rx_counter0)
>>
>> {
>>
>> ch = getchar();
>>
>> }
>>
>>
>>
>> You can actually check this for a certain value if you happen to know the
>> length of the data otherwise, you have to deal with variable length
>> input.
>>
>>
>>
>> Hope this helps?
>>
>> Dave.
>>
>>
>>
>> From: AVR-Chat@yahoogroups.com [mailto:AVR-Chat@yahoogroups.com] On
>> Behalf
>> Of Ahmed Mostafa
>> Sent: 08 July 2011 01:40
>> To: AVR-Chat@yahoogroups.com
>> Subject: [AVR-Chat] time of getchar
>>
>>
>>
>>
>>
>> command "getchar()"
>> if it didn't receive serial data
>> does it skips this command or what
>> and if it skips it , how long does it take
>> since this command "getchar()" is executed until it skips it ?
>>
>>
>>
>>
>>
>> [Non-text portions of this message have been removed]
>>
>>
>2011-07-08 by Dave McLaughlin
Sorry, I just noticed this was AVR chat so you may not be using Codevision. Which compiler are you using? If you are doing your own interrupt handler you can define any variable name you wish. Dave..
From: AVR-Chat@yahoogroups.com [mailto:AVR-Chat@yahoogroups.com] On Behalf Of Ahmed Mostafa Sent: 08 July 2011 16:33 To: AVR-Chat@yahoogroups.com Subject: Re: [AVR-Chat] time of getchar and if i use interrupt pleause clarify to me how to define variable rx_counter0 in the interrupt routine [Non-text portions of this message have been removed]
2011-07-08 by ho hoh
به نام خدا
hi
your code is not right for this application.
you can follow this code to arrive to your idea:
if(UCSRA & 0x80)
{
data=getchar();
}
code written for ATMEGA16.
http://up.vatandownload.com/images/c2s9tmogjxqtmw3i2kw.jpg
I saw you "read USART section of your AVR datasheet carefully" and say you again
, read your AVR datasheet carefully , you will find your answer.
________________________________From: Ahmed Mostafa <justforstudy2011@gmail.com>
To: AVR-Chat@yahoogroups.com
Sent: Friday, July 8, 2011 13:45:32
Subject: Re: [AVR-Chat] time of getchar
thanks for your help
actually i don't use interrupt
and if it didn't receive data , i want it to skip the getchar command
so can i use
if(getchar()) //instead of if(rx_counter0)
{
ch = getchar();
}
[Non-text portions of this message have been removed]2011-07-08 by ho hoh
It is not true :
rx_counter0
true is :
rx_counter!=0
and this variable will be declared by codevision codewizard
________________________________From: Ahmed Mostafa <justforstudy2011@gmail.com>
To: AVR-Chat@yahoogroups.com
Sent: Friday, July 8, 2011 14:03:24
Subject: Re: [AVR-Chat] time of getchar
and if i use interrupt
pleause clarify to me how to define variable rx_counter0 in the
interrupt routine
On 7/8/11, Ahmed Mostafa <justforstudy2011@gmail.com> wrote:
> thanks for your help
> actually i don't use interrupt
> and if it didn't receive data , i want it to skip the getchar command
> so can i use
>
> if(getchar()) //instead of if(rx_counter0)
> {
> ch = getchar();
> }
>
>
> On 7/8/11, Dave McLaughlin <dave_mclaughlin@nerdshack.com> wrote:
>> Hi there,
>>
>>
>>
>> I am assuming you are using an interrupt driven serial port here? Best
>> option by the way as it gets filled under interrupts so less likely to
>> lose
>> data. The following applies if this is turned on.
>>
>>
>>
>> You need to check the variable rx_counter0 (check your code for the
>> correct
>> name) before calling getchar()
>>
>>
>>
>> If this is non-zero it indicates there is data in the buffer.
>>
>>
>>
>> if(rx_counter0)
>>
>> {
>>
>> ch = getchar();
>>
>> }
>>
>>
>>
>> You can actually check this for a certain value if you happen to know the
>> length of the data otherwise, you have to deal with variable length
>> input.
>>
>>
>>
>> Hope this helps?
>>
>> Dave.
>>
>>
>>
>> From: AVR-Chat@yahoogroups.com [mailto:AVR-Chat@yahoogroups.com] On
>> Behalf
>> Of Ahmed Mostafa
>> Sent: 08 July 2011 01:40
>> To: AVR-Chat@yahoogroups.com
>> Subject: [AVR-Chat] time of getchar
>>
>>
>>
>>
>>
>> command "getchar()"
>> if it didn't receive serial data
>> does it skips this command or what
>> and if it skips it , how long does it take
>> since this command "getchar()" is executed until it skips it ?
>>
>>
>>
>>
>>
>> [Non-text portions of this message have been removed]
>>
>>
>
[Non-text portions of this message have been removed]2011-07-08 by David Kelly
On Fri, Jul 08, 2011 at 07:28:30AM -0700, ho hoh wrote:
> ???? ?????? ??????
> hi
> your code is not right for this application.
> you can follow this code to arrive to your idea:
> if(UCSRA & 0x80)
> {
> data=getchar();
> }
> code written for ATMEGA16.
> http://up.vatandownload.com/images/c2s9tmogjxqtmw3i2kw.jpg
> I saw you "read USART section of your AVR datasheet carefully" and say you again
> , read your AVR datasheet carefully , you will find your answer.
This is a terrible thing to do: mixing direct access to the USART
registers with canned library routines. Also don't write 0x80, use the
symbolic label from the datasheet. The actual bit may change with a
different flavor of AVR and by using the symbolic label your code stands
a better chance of porting without changes.
If you are going to play with USART bits directly then skip getchar():
if( UCSRA & (1<<RXC) )
data = UDR0;
else
data = -1; // indicate nothing available
The above is all one has to do to read a character from an initialized
USART.
--
David Kelly N4HHE, dkelly@HiWAAY.net
========================================================================
Whom computers would destroy, they must first drive mad.