UART setup for 801C188EB/80186

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
I am having some trouble setting up UART for a 80188 processor. Could
someone please point me in the right direction. I think I am making the
simple program more complicated.

the 16 Mega hz freq is configured to baud 9600.

void main()
{
    serialinit();
    serialput(41);
    serial_puts("nHello World");
}

serialinit()
{
outport(FF60,80CF);
outport(FF74,0x40);
}

serialput(int n)
{
    int status= inport(0xFF66)
    while (status!=0x08);
    outport(FF6A,n);
}

void serial_puts(char str[])
{
    int i;
    for( i=0;i<n;i++)
        {
         int status=inport(ff66);
        while (status!=0x08);
        outport(0XFF6A,str[i])
}

i just cannot see anything on the tera term when i connect it. Should it
be in a repeated while loop?


As i do not have an IDE to debug, i am confused how to go ahead and solve
this problem. I have to use make files to compile and compiler is borland.
If someone could point me in a right direction to solve it, that would be
great.



---------------------------------------
Posted through http://www.EmbeddedRelated.com


Re: UART setup for 801C188EB/80186
On Wed, 14 Oct 2015 19:44:29 -0500, srao wrote:

Quoted text here. Click to load it

Comments won't change how the code runs, but it might help people read it.

I'm not looking at my 80C186 data sheet -- does the UART have a dedicated  
pin, or does it share a GPIO pin?  If it's shared, do you have to do  
something to switch it over?  Did you?

--  

Tim Wescott
Wescott Design Services
We've slightly trimmed the long signature. Click to see the full one.
Re: UART setup for 801C188EB/80186
On Thu, 15 Oct 2015 00:40:51 -0500, Tim Wescott wrote:

Quoted text here. Click to load it

This can't be the code that you're running, because what you have here  
won't compile.

But have you considered the infinite loop in serial_puts?  You need to  
put the status read inside of the "while" loop, or it'll either always  
drop through or it'll always get stuck there.

If you have any blinky lights, or any spare GPIO that you can monitor  
with an oscilloscope or meter, use them in lieu of "printf" as a  
debugging tool.  Start by using them to see how far you're getting in  
your main loop, then how you're doing inside of any troublesome  
functions, etc.

--  
www.wescottdesign.com

Re: UART setup for 801C188EB/80186


Sorry for not adding comments.
 serialinit()
Quoted text here. Click to load it

   //FF66 is transmit buffer register

UART Is a dedicated PIN for this port. SO I have not done anything other
than this. Another concern which i think might be hampering this is the
watchdog timer. Its set to go off after an interval, I am not sure how to
toggle it to make sure my while loop runs.
---------------------------------------
Posted through http://www.EmbeddedRelated.com


Re: UART setup for 801C188EB/80186
@EmbeddedRelated says...
Quoted text here. Click to load it

Have you tried connecting a scope to see what is happening and where, so  
many different possible points of failure from cabling to software.
  
Quoted text here. Click to load it

As from memory 80188 werer normally just a processor we have no idea  
what UART you are using. 80188 was just an 8 bit external data bus  
version of 80186

Personally I did not realise many folks still making 80188 from about 30  
years ago.


--  
Paul Carpenter          | snipped-for-privacy@pcserviceselectronics.co.uk
<http://www.pcserviceselectronics.co.uk/ PC Services
We've slightly trimmed the long signature. Click to see the full one.
Re: UART setup for 801C188EB/80186
Quoted text here. Click to load it
 

many different possible points of failure from cabling to software.
Quoted text here. Click to load it
continuous high pulse after i turned it on. I am guessing the watch dog
timer might be creating the issues.  


Yes this is a modification to on old boot code. Thats the reson this
processor is in use. I know pin 9 is the watchdog input. When I need to
toggle it, do i need to reconfigure it as this is a GPIO? What would be
the procedure to toggle it?


-srao  


Quoted text here. Click to load it
Add-ons

Quoted text here. Click to load it
Font

Quoted text here. Click to load it

---------------------------------------
Posted through http://www.EmbeddedRelated.com


Re: UART setup for 801C188EB/80186
Quoted text here. Click to load it

Although I don't know the 80x188 in detail the following line looks  
strange to me.
Quoted text here. Click to load it
I think you mean "status & 0x8" if you want to test if the bit is set.
Normally the status register for a UART has several bits for each
status like receiver ready, transmitter ready, parity error ...


Re: UART setup for 801C188EB/80186
Op 15-Oct-15 om 18:20 schreef Peter Heitzer:
Quoted text here. Click to load it

Besides that, the status register is only read once and the status  
variable is not updated in the while loop. If the status register is not  
0x08 before it entered the while loop, the while loop will run forever.

Re: UART setup for 801C188EB/80186

Yes, I understand. I am wondering now, if its required to check if the
transmit buffer is empty? TXE is one of the bit which denoted the buffer
is empty(set to 1 if empty) Out of the several bits.. is there a way i can
check only this bit?
---------------------------------------
Posted through http://www.EmbeddedRelated.com


Re: UART setup for 801C188EB/80186
On Thu, 15 Oct 2015 15:48:07 -0500, srao wrote:

Quoted text here. Click to load it

Haven't been programming long?

Do a logical OR -- if the one bit is bit 3, then

((status ^ 0x08) != 0)

will return true if the status bit is set, and false if not.

--  

Tim Wescott
Wescott Design Services
We've slightly trimmed the long signature. Click to see the full one.
Re: UART setup for 801C188EB/80186
Quoted text here. Click to load it
buffer

Quoted text here. Click to load it

Thanks TIM. Yes, been a while. N I accept this last part was a unnecessary
question. Do u know how to go about the watchdog timer. I need to keep it
kicking. The pin of the processor which takes the input is P1.5 (GCS5) I
can see there ate two registers associated with it. GCS5ST, GCS5SP for
start and stop registers. i didnt get an idea what they mean.? thoughts?
---------------------------------------
Posted through http://www.EmbeddedRelated.com


Re: UART setup for 801C188EB/80186
On Thu, 15 Oct 2015 17:08:11 -0500, srao wrote:

Quoted text here. Click to load it

Study that data sheet, 'cause I don't know either!

If it's like the watchdog timers I'm used to, you need to reset it in  
software before it times out, or it'll reset the processor.  The idea is  
that if your program hangs the watchdog resets it.

You really ought to implement a task loop instead of blocking on status  
flags.

I looked for a web reference and didn't find it.  The basics are that  
everything that needs to get serviced has a state associated with it, and  
a function.  Your main program is a loop that just calls all of the  
functions in turn (there are other ways to do this -- this is the  
simplest).

Each function looks at its state, looks at whatever hardware it is  
servicing, then does whatever it needs to do based on those two things,  
possibly writing to hardware and/or changing its state in the process.  
Functions _never, ever_ waste time -- so no "while (status)" loops are  
allowed.  Instead, you'd have something like "if I have stuff to  
transmit, and the transmitter is ready, write a byte to the transmitter  
and update my 'stuff to transmit' pointer".

Task loops are what you do instead of implementing RTOSs, when the  
problem is small enough.

--  

Tim Wescott
Wescott Design Services
We've slightly trimmed the long signature. Click to see the full one.
Re: UART setup for 801C188EB/80186
Quoted text here. Click to load it

The terms I'm used to for this is "event loop" or "state machine".

Re: UART setup for 801C188EB/80186

Quoted text here. Click to load it
 

Quoted text here. Click to load it
 

Quoted text here. Click to load it


Yes, I understand. I will look into it, and modify the program according
to your suggestions. I used a while loops just to make sure, i could see
something on the scope. Figured the watchdog timer stuff. Like you said,
they do reset if the program hangs, so I am planning to keep toggling
watchdog and not allow it to kick.
---------------------------------------
Posted through http://www.EmbeddedRelated.com


Re: UART setup for 801C188EB/80186
Tim Wescott wrote:

Quoted text here. Click to load it

You mean _bitwise_and_

 ((status & 0x08) != 0)

--  
Reinhardt


Re: UART setup for 801C188EB/80186
On Fri, 16 Oct 2015 07:21:25 +0800, Reinhardt Behm wrote:

Quoted text here. Click to load it

Good lord yes!  What was I thinking?

--  

Tim Wescott
Wescott Design Services
We've slightly trimmed the long signature. Click to see the full one.
Re: UART setup for 801C188EB/80186
Quoted text here. Click to load it
buffer

Quoted text here. Click to load it


Did something like this:-

    while(1)
      {

     for (N loops) //togggle watchdog
       {
           //port1 clear bits            
           Set bit on watchdog PIN
           outport(0x00xx,a);
       }

       for (N loops)
       {
           //port1 clear bits            
           //Clear bit on watchdog PIN
            outport(0x00xx,a);
       }
---------------------------------------
Posted through http://www.EmbeddedRelated.com


Re: UART setup for 801C188EB/80186

Quoted text here. Click to load it
not sure if I am doing something wrong here. the above code does not
toggle the Port pin. is there a better way to solve this?


---------------------------------------
Posted through http://www.EmbeddedRelated.com


Re: UART setup for 801C188EB/80186
On 10/16/2015 7:33 PM, srao wrote:
Quoted text here. Click to load it

Where do you change the value written to the port?  You don't even show  
where you set the value of 'a' initially.

--  

Rick

Re: UART setup for 801C188EB/80186
Quoted text here. Click to load it

The OP _really_ needs to show us _actual_ code not the above pseudo code.

Also, the above sequence "feels" really wrong to me. Why is the port
pin being set N times and then cleared N times ?

With a watchdog you are supposed to send a specific sequence _once_
every time you decide to report that you are still alive and not stuck.

Simon.

--  
Simon Clubley, clubley@remove_me.eisner.decus.org-Earth.UFP
Microsoft: Bringing you 1980s technology to a 21st century world

Site Timeline