EmbeddedRelated.com
Forums

UART setup for 801C188EB/80186

Started by srao October 14, 2015
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
On Wed, 14 Oct 2015 19:44:29 -0500, srao wrote:

> 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.
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 http://www.wescottdesign.com
In article <_JudnRc6Yatwa4PLnZ2dnUU7-YHOydjZ@giganews.com>, 109468
@EmbeddedRelated says...
> > 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?
Have you tried connecting a scope to see what is happening and where, so many different possible points of failure from cabling to software.
> 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.
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 | paul@pcserviceselectronics.co.uk <http://www.pcserviceselectronics.co.uk/> PC Services <http://www.pcserviceselectronics.co.uk/pi/> Raspberry Pi Add-ons <http://www.pcserviceselectronics.co.uk/fonts/> Timing Diagram Font <http://www.badweb.org.uk/> For those web sites you hate
srao <109468@embeddedrelated> wrote:
>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.
>serialput(int n) >{ > int status= inport(0xFF66)
Although I don't know the 80x188 in detail the following line looks strange to me.
> while (status!=0x08);
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 ...
On Thu, 15 Oct 2015 00:40:51 -0500, Tim Wescott wrote:

> On Wed, 14 Oct 2015 19:44:29 -0500, srao wrote: > >> 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. > > 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?
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
Op 15-Oct-15 om 18:20 schreef Peter Heitzer:
> srao <109468@embeddedrelated> wrote: >> 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. > >> serialput(int n) >> { >> int status= inport(0xFF66) > Although I don't know the 80x188 in detail the following line looks > strange to me. >> while (status!=0x08); > 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 ... >
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.

Sorry for not adding comments.
 serialinit()
>> { >> outport(FF60,80CF); // set baud rate in BCMP compare register >> outport(FF74,0x40); // set mode synchronous mode 0
//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
>Have you tried connecting a scope to see what is happening and where, so
many different possible points of failure from cabling to software.
> I have connected scope and I was not able to see data. All i saw was a
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
> >-- >Paul Carpenter | paul@pcserviceselectronics.co.uk ><http://www.pcserviceselectronics.co.uk></http:> PC Services ><http://www.pcserviceselectronics.co.uk/pi></http:> Raspberry Pi
Add-ons
><http://www.pcserviceselectronics.co.uk/fonts></http:> Timing Diagram
Font
><http://www.badweb.org.uk></http:> For those web sites you hate
--------------------------------------- Posted through http://www.EmbeddedRelated.com
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
On Thu, 15 Oct 2015 15:48:07 -0500, srao wrote:

> 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?
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 http://www.wescottdesign.com