Searching \ for '[PIC]: putrsUSART() breaking DataRdyUSART()' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: techref.massmind.org/techref/microchip/ios.htm?key=usart
Search entire site for: 'putrsUSART() breaking DataRdyUSART()'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: putrsUSART() breaking DataRdyUSART()'
2006\02\06@074647 by Vitaliy

flavicon
face
Hello List,

I have a little circuit which uses a PIC18F4320, whose Tx/Rx lines are tied
together (Tx is connected through a diode, so it can only drive the bus
low). It's very similar to the Parallax AppMods.

Now, any time I use putrsUSART(), it causes the DataRdyUSART() function to
stop working. I attached the source code to this message. If you were to
compile and run it as-is, and type "ABCDEFG" in HyperTerminal, you would
see:

   AABBCCDDEEFFGG

However, if you were to uncomment the putrsUSART() function, you would get:

   Hello World!

   ABCDEFG

For some reason, after the putrsUSART() function is used, DataRdyUSART()
never evaluates to TRUE.

A couple of observations:

1. Closing/opening the port after using the putrsUSART() fixes the problem.
2. putcUSART() does not have this issue.

I have a feeling that I am overlooking something very obvious. Any help with
this matter is greatly appreciated!

Best regards,

Vitaliy

---------- Source Code -------------------

#include <p18f4320.h>
#include <delays.h>
#include <usart.h>

/* Set configuration bits for use with ICD2 / PICDEM2 PLUS Demo Board:
*  - set HS-PLL oscillator
*  - disable watchdog timer
*  - disable low voltage programming
*  - enable background debugging
*/

#pragma config OSC = HSPLL
#pragma config WDT = OFF
#pragma config LVP = OFF
#pragma config DEBUG = ON

void main(void)
{
 char c;

  //Open the USART configured as 8N1 in polled mode
 OpenUSART (USART_TX_INT_OFF &
              USART_RX_INT_OFF &
              USART_ASYNCH_MODE &
              USART_EIGHT_BIT &
              USART_CONT_RX &
              USART_BRGH_LOW, 255);

 //putrsUSART((const far rom char *)"\rHello World!\r");

 while (BusyUSART()); // wait until transmission is complete

  for (;;)
  {
     if (DataRdyUSART())  // check USART read buffer
     {
        c = getcUSART();           // read character
        putcUSART(c);              // echo it back
        while (BusyUSART());       // wait until transmission is complete
        Delay1KTCYx(4);            // wait some more
        while (DataRdyUSART())     // empty the receive buffer
           getcUSART();
     }
  }
}

2006\02\07@010207 by Vitaliy

flavicon
face
Guys, there wasn't a single reply -- did this post make it to the list?


----- Original Message -----
From: "Vitaliy" <spam_OUTspamTakeThisOuTspammaksimov.org>
To: "piclist" <.....PICLISTKILLspamspam@spam@mitvma.mit.edu>
Sent: Monday, February 06, 2006 5:45 AM
Subject: [PIC]: putrsUSART() breaking DataRdyUSART()


{Quote hidden}

2006\02\07@013039 by piclist

flavicon
face
The compiler includes the source code to the library routines, so you
should be able to figure out what's going on.  Though I would suggest
that instead of spending time on that, don't use the library routines,
and use the time to learn how the UART works and to write your own
code.

On Mon, 6 Feb 2006, Vitaliy wrote:

> Guys, there wasn't a single reply -- did this post make it to the list?
>
>
> {Original Message removed}

2006\02\07@013645 by WH Tan

flavicon
face
Hi,

> Guys, there wasn't a single reply -- did this post make it to the list?

Don't worry. Received lound and clear :)

First, the line while(BusyUSART()); after putrsUSART() is superfluous (even
putrsUSART() is not commented out). So remove it.

Secondly, try this in your for loop:


  for (;;)
  {
     if (DataRdyUSART())  // check USART read buffer
     {
        c = getcUSART();           // read character
        while (BusyUSART());       // check before you
                                               // write to,
                                   // instead of
                                   // after!

        putcUSART(c);              // echo it back


        //Delay1KTCYx(4);          // This line is unnecessary

        //while (DataRdyUSART())   // same here, unnecessary
        //   getcUSART();
     }
  }



Best regards,

WH Tan

2006\02\07@014037 by Chen Xiao Fan

face
flavicon
face

> -----Original Message-----
> From: piclist-bouncesspamKILLspammit.edu
> [.....piclist-bouncesKILLspamspam.....mit.edu] On Behalf Of Vitaliy
>
> Guys, there wasn't a single reply -- did this post make it to
> the list?

It has hit the list but the C18 experts have not seen it. ;-)

Maybe Microchip Forum is another place to post the questions.
I am quite new to C18 but it seems that the code is not
the same as what I see in the examples.

I tried to use the simulator but I have yet to learn how to
use the simulator effectively yet. From the simulator run,
it seems that you have an overrun error here
(USART_Status.OVERRUN_ERROR = 1) with the helloworld line.

When you uncomment the helloworld line, you do not have
have that error.

I remember there is a thread  related to this problem
in the C18 forum. You may want to check it out.

Regards,
Xiaofan

2006\02\07@090454 by olin piclist

face picon face
Vitaliy wrote:
> Guys, there wasn't a single reply -- did this post make it to the list?

Yes.

>> Now, any time I use putrsUSART(), it causes the DataRdyUSART()

I can't speak for others, but I didn't reply for several reasons.

First, I have no idea what putrsUSART() is supposed to do and what
environment you were talking about.  This looks like some high level
language problem, which might get into runtime library issues, which are
nearly impossible or pointless to try and debug on the list, and I didn't
feel like playing 20 questions distill this problem down to the few
essential assembler instructions so we can see what's really going on and
have half a chance of fixing the problem.

Second, I wouldn't answer this here as long as James subjects my posts to
censorship.  If you can distill this to something answerable, try asking on
the Microchip forums.  Actually that's a good idea anyway for direct PIC
questions.  They generally get answered quicker and more directly there.
This list is better for rambling discussions, but if you want specific help
go to the Microchip forums.


******************************************************************
Embed Inc, Littleton Massachusetts, (978) 742-9014.  #1 PIC
consultant in 2004 program year.  http://www.embedinc.com/products

2006\02\07@232800 by Vitaliy

flavicon
face
Sorry for the late reply, didn't have a chance to get back to this until
now.

Xiaofan wrote:
> I tried to use the simulator but I have yet to learn how to
> use the simulator effectively yet. From the simulator run,
> it seems that you have an overrun error here
> (USART_Status.OVERRUN_ERROR = 1) with the helloworld line.

Bingo.

There's nothing wrong with the library. Remember I mentioned that the Tx/Rx
lines are connected? Well, what happens is as I transmit the string, it gets
fed into the Rx pin, and causes buffer overflow. Like I said, I was
overlooking something very obvious.

My plan is to write a custom putrs replacement, that would either disable
the receiver while it's transmitting, or read the buffer after it sends
every character.

Thanks, Xiaofan!

Vitaliy

2006\02\08@002156 by Chen Xiao Fan

face
flavicon
face

> -----Original Message-----
> From: EraseMEpiclist-bouncesspam_OUTspamTakeThisOuTmit.edu
> [piclist-bouncesspamspam_OUTmit.edu]On Behalf Of Vitaliy
>
> There's nothing wrong with the library. Remember I mentioned
> that the Tx/Rx lines are connected? Well, what happens is
> as I transmit the  string, it gets  fed into the Rx pin,
> and causes buffer overflow. Like I said, I was  overlooking
> something very obvious.
>
> Thanks, Xiaofan!
>
> Vitaliy

Thanks for reporting back the real cause of the problem. I will
say it is not that obvious. At least I do not know until now.

In fact, I seldom used the MPLAB simulator but it seems that
it can really help out with debugging.

In this case, I was following the MPSIM tutorial "Getting Started
with MPLAB SIM --Using a USART/UART" yesterday and tried the code.
MPSIM is really useful especially because that it steps into the
source codes for the library functions.

Regards,
Xiaofan

2006\02\08@221548 by Vitaliy

flavicon
face
Olin wrote:
>>> Now, any time I use putrsUSART(), it causes the DataRdyUSART()
>
> I can't speak for others, but I didn't reply for several reasons.
>
> First, I have no idea what putrsUSART() is supposed to do and what
> environment you were talking about.  This looks like some high level
> language problem, which might get into runtime library issues, which are
> nearly impossible or pointless to try and debug on the list, and I didn't
> feel like playing 20 questions distill this problem down to the few
> essential assembler instructions so we can see what's really going on and
> have half a chance of fixing the problem.

First, the program that I was debugging consists of several modules, and the
listing that I submitted to PicList distills the problem to its essense.

Second, it sounds like you do most of your coding in Assembler, and you're
not familiar with C18 Compiler Libraries. That is of course your choice, but
it also makes me believe that you couldn't have helped with this particular
problem anyway.

> Second, I wouldn't answer this here as long as James subjects my posts to
> censorship.  If you can distill this to something answerable, try asking
> on
> the Microchip forums.  Actually that's a good idea anyway for direct PIC
> questions.  They generally get answered quicker and more directly there.
> This list is better for rambling discussions, but if you want specific
> help
> go to the Microchip forums.

That is your opinion to which you are, of course, entitled. However, a
PicList member did help me solve the problem, and from what I hear Microchip
forums are full of people who speak English as their 27th language.

I will certainly ask questions on the Microchip forum as well. Although for
some reason, "mailing list" still feels more real-time than "forum."

Best regards,

Vitaliy

2006\02\09@073443 by olin piclist

face picon face
Vitaliy wrote:
> I will certainly ask questions on the Microchip forum as well. Although
> for some reason, "mailing list" still feels more real-time than "forum."

I don't think of either as real time, although I think the Microchip forums
will actually get you a quicker response to a specific PIC-related question
like yours was.  There is also a wider audience there, so there is a better
chance of someone knowing what you are talking about.  The PIClist is better
for general discussions not aimed at a specific Microchip-related problem.


******************************************************************
Embed Inc, Littleton Massachusetts, (978) 742-9014.  #1 PIC
consultant in 2004 program year.  http://www.embedinc.com/products

2006\02\09@073729 by olin piclist

face picon face
Vitaliy wrote:
> I will certainly ask questions on the Microchip forum as well. Although
> for some reason, "mailing list" still feels more real-time than "forum."

PS to my previous post:

The forums seem to be down right now (7:39am Eastern US time), so don't go
away thinking you're doing something wrong if you are trying to go there for
the first time.


******************************************************************
Embed Inc, Littleton Massachusetts, (978) 742-9014.  #1 PIC
consultant in 2004 program year.  http://www.embedinc.com/products

2006\02\09@091859 by John Nall

picon face
Olin Lathrop wrote:
> > I don't think of either as real time, although I think the Microchip forums
> will actually get you a quicker response to a specific PIC-related question
> like yours was.  There is also a wider audience there, so there is a better
> chance of someone knowing what you are talking about.  The PIClist is better
> for general discussions not aimed at a specific Microchip-related problem.
>  
.
I don't know as I agree with that.  Or at least not completely.  I read
both the piclist and  the Microchip forums (or at least those
subsections in the forum that are of interest), and while I agree that
there is a wider audience there, the noise level is also a lot higher
(if you leave out the [OT] postings of  the piclist).  The vast majority
of that wider audience seems to be beginners, with a few experts (such
as yourself) spread thin.  I may be wrong, but that is the impression I  
get.

Personally, I like to use both the piclist and the forums, but if I
could only have one then it would be the piclist.

John

2006\02\09@092100 by Xiaofan Chen

face picon face
On 2/9/06, Olin Lathrop <@spam@olin_piclistKILLspamspamembedinc.com> wrote:
> Vitaliy wrote:
> > I will certainly ask questions on the Microchip forum as well. Although
> > for some reason, "mailing list" still feels more real-time than "forum."
>
> PS to my previous post:
>
> The forums seem to be down right now (7:39am Eastern US time), so don't go
> away thinking you're doing something wrong if you are trying to go there for
> the first time.
>

There are several problems with Microchip Forum. It has been down for several
hours already. My biggest complain to the Microchip forum is that
attachments are often lost. In fact the forum software update throws away
almost all the old attachment files.

But I must agree with Olin that it is better to go to Microchip Forum
for more specific PIC questions and more advanced PIC related topics
(like C18, C30, dsPIC, USB, ... ). This does not mean that PIClist is not
good. PIClist is good! It can be better though.

Regards,
Xiaofan

2006\02\09@234853 by William Chops Westfield

face picon face

On Feb 9, 2006, at 6:18 AM, John Nall wrote:

> The vast majority of that wider audience [on microchip forums]
> seems to be beginners, with a few experts spread thin.

That's sort of of the impression I've gotten as well.  Ask a
moderately complex technical question on PICLIST, and even if
no one knows the answer you end up getting an interesting technical
discussion (sometimes gradually devolving into far OT) that is
educational.  Similar questions on manufacturers forums tend to
result in ... silence.

BillW

2006\02\09@235651 by Bob Axtell

face picon face
William Chops Westfield wrote:

> That's sort of of the impression I've gotten as well. Ask a
>
>moderately complex technical question on PICLIST, and even if
>no one knows the answer you end up getting an interesting technical
>discussion (sometimes gradually devolving into far OT) that is
>educational.
>  
>
That's because we are a bunch of almost-retired primadonnas.

--Bob

>BillW
>
>  
>


--
Note: To protect our network,
attachments must be sent to
KILLspamattachKILLspamspamengineer.cotse.net .
1-520-850-1673 USA/Canada
http://beam.to/azengineer

2006\02\10@080556 by John Nall

picon face
Bob Axtell wrote:
> William Chops Westfield wrote:
>
>  
>> That's sort of of the impression I've gotten as well. Ask a
>>
>> moderately complex technical question on PICLIST, and even if
>> no one knows the answer you end up getting an interesting technical
>> discussion (sometimes gradually devolving into far OT) that is
>> educational.
>>  
>>
>>    
> That's because we are a bunch of almost-retired primadonnas.
>
> --Bob
>  
.
Whatever the reason, I find it very helpful (and educational, as
stated).  Lots of times a question is answered that was not even posed,
but to which the answer is important.  :-)

2006\02\13@101945 by alan smith

picon face
wish I was that close....nuther 25 years for me to generate a retirement income
 
 Like I tell my wife.....one day, be nice to take a job...do it for 3 or 4 weeks....go on a vacation.....recover from the vacation....then do another job....

Bob Axtell <RemoveMEengineerTakeThisOuTspamcotse.net> wrote:
 William Chops Westfield wrote:

> That's sort of of the impression I've gotten as well. Ask a
>
>moderately complex technical question on PICLIST, and even if
>no one knows the answer you end up getting an interesting technical
>discussion (sometimes gradually devolving into far OT) that is
>educational.
>
>
That's because we are a bunch of almost-retired primadonnas.

--Bob

>BillW
>
>
>


--
Note: To protect our network,
attachments must be sent to
spamBeGoneattachspamBeGonespamengineer.cotse.net .
1-520-850-1673 USA/Canada
http://beam.to/azengineer

2006\02\13@104228 by Bob Axtell

face picon face
alan smith wrote:

>wish I was that close....nuther 25 years for me to generate a retirement income
>  
>  Like I tell my wife.....one day, be nice to take a job...do it for 3 or 4 weeks....go on a vacation.....recover from the vacation....then do another job....
>  
>
Being an engineer has not been lucrative. I have always made more money
shooting craps and playing Texas Hold'm poker than I ever
made as an engineer, no matter how large the contract was.

Engineering is not a high-paying profession.. but it has the rewards of
a job well done.

Have your wife become an RN. THAT'S a high-paying profession. Mine is.

--Bob.




--
Note: To protect our network,
attachments must be sent to
TakeThisOuTattachEraseMEspamspam_OUTengineer.cotse.net .
1-520-850-1673 USA/Canada
http://beam.to/azengineer

2006\02\13@114323 by Danny Sauer

flavicon
face
Bob wrote regarding 'Re: [PIC]: putrsUSART() breaking DataRdyUSART()' on Mon, Feb 13 at 09:54:
> Have your wife become an RN. THAT'S a high-paying profession. Mine is.

It also gets you the only kind of nurse whose medical knowledge is
actually accurate (nurse practitioner non withstanding). :)  In-house
medical knowledge is really handy, so long as it comes from education
and not "I heard half of a conversation at the hospital and it sounded
similar to this situation"...

--Danny

2006\02\13@135257 by alan smith

picon face
ya...well....im inventing the next great widget to make me millions  :-)  Then I can work for fun....
 
 ok...so im dreaming the impossible dream!

Bob Axtell <RemoveMEengineerspamTakeThisOuTcotse.net> wrote:
 alan smith wrote:

>wish I was that close....nuther 25 years for me to generate a retirement income
>
> Like I tell my wife.....one day, be nice to take a job...do it for 3 or 4 weeks....go on a vacation.....recover from the vacation....then do another job....
>
>
Being an engineer has not been lucrative. I have always made more money
shooting craps and playing Texas Hold'm poker than I ever
made as an engineer, no matter how large the contract was.

Engineering is not a high-paying profession.. but it has the rewards of
a job well done.

Have your wife become an RN. THAT'S a high-paying profession. Mine is.

--Bob.




--
Note: To protect our network,
attachments must be sent to
attachEraseMEspam.....engineer.cotse.net .
1-520-850-1673 USA/Canada
http://beam.to/azengineer

2006\02\13@172740 by James Humes

picon face
Hey, thats not true!  (in an encouraging way)  I work for a guy who "built
the better mousetrap" for a device with a small market (about 30K/year) and
he's living the dream.  He built a big house across the street and uses his
old house as the lab/office.  Keep at it!

James


On 2/13/06, alan smith <EraseMEmicro_eng2spamyahoo.com> wrote:
>
> ya...well....im inventing the next great widget to make me
> millions  :-)  Then I can work for fun....
>
> ok...so im dreaming the impossible dream!
>

More... (looser matching)
- Last day of these posts
- In 2006 , 2007 only
- Today
- New search...