New Breadboard 8088 PC V2 #7 Serial Port Software & Testing

New Breadboard 8088 PC V2 #7 Serial Port Software & Testing

Show Video

welcome to breadboarding In the previous video we managed to get our modern surface mount UART serial communications chip soldered onto a 48 pin DIP adapter here And we wired it all up and we're now in a position to sort the software out and start testing it So this is video 7 in the breadboard PC 8088 version 2 series And this video we're going to be covering the serial port software and testing it So almost got to the end of the first phase of our highle plan So this is building out our nanomp 8088 This is a simple computer using an LED display and keypad running the nanomp monitor which has been migrated from the original 689 monitor from the project a number of years ago And in this video we're going to be getting the serial port software to save and load data to the computer memory in the SRCord file format So Srecord is a file format that allows binary data to be transferred up and down over serial connections and includes a certain amount of error checking in it And this will enable us then to have a platform that we can then build out the basic floppy disc PC and gives us uh something to do the test software and to check out all the hardware here as we're building it And then we'll move on to add a hard disk mouse and extend the CGA video controller to all modes including graphics mode And we should then be able to run Windows 1 2 and three like we did in the first series So let's take a look at the data sheet First of all we did cover some of the details in here in the previous video but what I'm going to do now is to look at the registers that we need to worry about for configuring and programming this So you'll see here that we have three address lines That gives us a possible eight register options But because we also have this DLAB bit for the device a latch bit here that allows us to access device latch least significant bite and the device latch most significant bite depending off if that bit is set in the line control register So effectively gives us access to 10 registers even though we're only using eight addresses from our three address lines here So one of the reasons why this has been delayed a little is I had some problems with it trying to get it working And what I later find out is there was some interference on the master reset line that was actually resetting the status of the UART every probably some 2,000 times a second So it might be able to send one character but then the next characters would all then get messed up So once I worked out what that problem was then managed to make progress since then And this table here really is probably the most useful It summarizes what each of the registers is and there's an acronym that is used throughout the software and throughout the documentation And you can see here that the receive buffer register for where we receive the data from the PC the transmitter where we put the data to send to the PC And you can see that when the Dlab bit is zero then this is used for sending and receiving data and the interrupt enable register is also enabled when this bit is zero However when the bit is set to one which is actually set in the line status control register You'll see here the divisor latch access bit is set here When that is set then we can then access the divisor least significant bite and most significant bite to enable the board rate that we want So be going through these registers There's a special register here for the 16550 series which allows us to control the first in first out 16 byt buffer configuration By default it's disabled but if we write this register we can enable those facilities The BIOS and the early versions of DOSS didn't have support for this so we won't be worrying about that The line control register is probably the main one that we're going to be setting up the configuration where we have the divisor latch access bit plus also the word length and whether we want stop bits and no par The modem control register allows us to set the various mode and control signals for doing hardware handshaking with the PC The line status register allows us to check the current status for whether we've got data ready to read from the receive buffer and whether or not the transmitter holding register is empty and ready for another bite of data to be sent The modem status register allows us to check the modem control lines And there's a scratch register which you'll see there's a bit of test code in there where I was testing out whether we were setting the correct bits and things in the data bus when I was having a few problems with the reset And then we've got the divisor registers here which we'll be setting to 12 which will give us a value of 9600 board So to help work out what software changes I need to make I went into the the BIOS Sergey Kislev's XI88 BIOS and looked at the serial 1.inc and serial 2.inc which is where all of the BIOS serial port communication services are And so this includes most of the register definitions and the various bit values we need to worry about So the transmitter holding register empty value and data ready for example are the two of the status values we need to worry about It's been useful to go through and look at what are the various values So setting the data terminal ready and RTS when we're sending data and when we're receiving data we just set data terminal ready for example So I've summarized a lot of the information from there into this slide here So basically this is just summary of the various bits and registers we need to worry about and I've included this in the source code above each of the send and receive functions So we don't need to go through this in detail here but needless to say we have to set this bit so we can send set our port divisor for the speed that we want initializing 8 bits one stop bit no parity which is pretty much the standard for PCs after about the mid80s Going to disable interrupts Make sure we set the appropriate modem control signals Then when we're receiving data we need to check that the line status register the line status register down here We need to check that the data ready is set that will indicate that there's some data available to read When we read the receive buffer then that bit will get cleared automatically And then when we're sending data before we write to the transmitting holding register we need to check the line status register bit 4 to see whether or not the register is empty or not So if we were to update this whilst it was still being sent then we could overwrite the data that we're already in the process of sending So we need to check these status bits before we receive or write data from the UART And the line control register has a couple of bits we need to worry about So we're going to be setting bit 0 and bit one to a value of three which gives us 8 bit words And then the stop bit value will be zero which gives us one stop bit And the problem I was having whilst I was testing this is at random intervals quite frequently like 2,000 times a second there was some interference on the reset line that would actually reset this back to zero So we'd end up with five bits rather than 8 bits which understandably messed things up in quite a big way So let's take a look at the versions of the software This is version seven the new version on the left hand side and version six the version that we had in the previous video on the right hand side So I'm just going to go through the changes we've made here So you'll see over here that the original 6850 Motorola UART had three registers we needed to worry about and this one has 10 So it's a bit more complicated And we've also now got all of the various bit values that we need to worry about when talking to the various registers in particular transmitter holding empty register and the data ready for the receive buffer Then we've just updated the version to version 7 So I'll just check that we've got the right version when we start up the monitor So this is the text I showed you on the previous slides This has just been copied in and modified specific to receive So most of the code here is to do with initialization of the UART In the 6850 there's just really one register we need to configure whereas this has quite a bit more So we're setting up the board rate then setting the line control register disable interrupts and then we're also setting the data terminal ready and request to send modem control signals And then we're into the rest of the code which is pretty much unchanged until we get to the code which is actually talking to the serial port So the receive bite is the bit that's talking to the serial port So first of all we actually have to check the modem status register to see whether we got the data set ready or the clear to send bits set So either one of those will satisfy the test It'll go around in that tight loop waiting for one of those bits to be set So this is the hardware flow control Then once we've got one of those hardware flow control bits set we then need to check that the ready bit is set So the ready bit being one means we've got some data that's been received And when we read the serial data buffer then that will clear that bit So we go around in that loop until such time as we've got some data we read the data and that will then clear that bit and then we return the data So then when we're going to send the data or save the data we got similar initialization The only real difference is that the modem control register we're only setting the data terminal ready in this particular case You'll see there's quite a few bits here commented out where I was trying various things to see what the problem was I was disabling the BIFO facilities explicitly and you'll see it's quite a few of no operations and reading in values and things and what I discovered is that the line control register is expected to be three the whole time and at various points it was getting zeroed which changed everything to five bits which was going to mess things up big time and you'll see as well that there's a test patterns I was using in the scratch register which is just a a register available for general purpose testing So I was just checking we were getting the right bit patterns coming through there All that's been disabled now And then I did come across a small bug in that when I was saving the data in a segment outside of the segment where the code was running from it was using the wrong segment for sending the address And so I've added a new facility So send byte DSX which uses a data segment and BX to send the data whereas the default one uses the extra segment So we've got another routine here and the only difference between these two routines is that this one uses the data segment This one uses the extra segment and that just means that the address bytes will appear in the S record file in the correct position Then when we're sending again some debug code there expecting to look at the line control register tower detected the problems we need to check the data set ready and the clear to send bits If one of those or one or both of those are set then we know we can carry on Otherwise we just wait until such time as one of those is set Then we need to test that the transmitter holding register is empty If it isn't empty we need to wait until such time as the data has been finished sending down the wire Once it's empty then we can actually send the data And that's the changes So all we need to do now is just to assemble that The monitor is still part of the BIOS So I'm just going to make the BIOS including the monitor And then we're just going to program that into the EPROM Just read it to make sure it's in the right way We just need to make sure that this is loaded 4K into the 32K prom to allow for the IDE BIOS to be loaded at a later stage Now our BIOS should start from 10 0 Yep Goes down to the bottom So we'll just program that We'll put that back into the computer Okay So here we have the UART here So this is our surface mount chip on the 48 pin DIP adapter The two extra lines here So the chip selects for the IOXX range and the IO3XX range I've missed out those I have also added two extra links in here So the problems I was talking about earlier to do with the interference on reset What I'm now doing is taking the active low reset from here feeding it into this side of the PLLD and making use of an unused pin here to generate the active high reset because this doesn't seem to have the same sort of problem So most of the problems I've had causing delays related to the interference on this and I'll show you some captures from the oscilloscope to show how that has changed Other than that I think everything else should be the same And you can see over here we've got a USB cable plugging into my laptop here into the USB serial converter So just going to turn it on first of all and we would expect to see the Nanomp 8088 monitor version 7 That's good So we got version 7 coming up here The voltage is a little bit below five but it's still uh within tolerance So that should be okay Now I'm just going to do is to put the oscilloscope on the oscillator here So just going to put that in first So I'm just going to check that we've got 1.8

MHz coming out of our oscillator here We'll just switch over to the oscilloscope There's the oscilloscope And if you look down the bottom here we can see the frequency is 1.844 MHz I'm also just going to put the probe onto the board out pin on the chip as well And we're just going to check to see what frequency is coming out of here Then you change the scale a little In fact when the chip is new then the default frequency you get is uh quite a lot lower than this But you can see here that in fact the frequency here is 153 kHz Now that happens to be the correct frequency for uh producing 9600 board So in fact if you divided that by 16 you would actually get 9600 board So the clocks look like they're okay So we're going to do now is to fire up the terminal program So I'm just going to do a very simple test First of all we're just going to send the first 16 bytes of the EPROM first of all So we'll be looking at what appears on here So we'll just now go into the monitor and we'll send the first 16 bytes of the monitor and we'll see what comes up on the display here Okay So what we need to do is first of all we're going to send the extra segment to be f 0 0 So this is the top area where the eprom is And then we're just going to do save 9 0 0 And the finish address is going to be 9 0 1 0 So we'll just switch back to the terminal And if I now press the zero and we can see we've actually got something coming up here Now this is in fact the S record format And what I'll do is we'll just do this again and I'll capture it this time So what I'm going to do is to clear the screen Start over We'll just do that again Okay so that's finished And if we have a look at the capture file that we've got here so you can see that this S1 and S9 are part of the SR record file format And if we save this as srec file and in fact Notepad++ is able to interpret these and if we have a look you can see there's actually some highlighting here and what this actually shows us I'll I'll show you a slide of what the S record format is but there's a check some on the end here and if for example this value was E rather than F then in fact it would show that the check sum was incorrect If we change this back and if we change the count of the number of bytes here then again this would show us that the number of bytes of data there is incorrect So the S record format is fairly straightforward and simple but it does allow us to check that the data sending is actually okay So if just have a look at the slides this is a slide I've got on the S record S19 record format This is just from Wikipedia So if you search for Srecord S19 and the key thing is here there's lots of different record types it supports for different sizes of data But the ones that we use is the S1 record type which bases for 16 bit address and bite data And then the S9 record is what the monitor looks for the end of the file And so the S9 just says this is the end of the file And there are check sums And the way how the check sums are calculated is based on the calculations here And the LED display on the monitor shows F for finished C if there's a checkum error and E if there's a hex decimal conversion error So if we had an invalid hexodimal value then that would get E on there Now I'm not going to test that for the moment because I've tested that in the first series on this So I know that that side of things works So the main thing we're interested in is is the serial communications working So just going to show you the problems that I had with the reset and how I fixed that So one of the reasons for this uh delay in getting this video out is that this problem has caused quite a bit of trouble So it was actually caused by the reset active high reset line as opposed to the active low reset line having interference on it and actually causing the UART problems in particular was causing the UART to reset up to 2,000 times a second which is never going to be good So this is the output of the oscilloscope of the probe grounded near where the reset line is on the UR chip This is actually oscilloscope probe on the reset line when it's supposed to be low when there isn't supposed to be any active reset Now the trigger on this was actually set at 2 VT which is the TTL minimum high value So any value over 2 VTs is interpreted as a TTL high value And you can see here with one volt per per division So the baseline value here this is 0 volts 1 volt 2 volt 3 volt 4 vol five So 5 volt is up here somewhere What you can see here is there are a number of instances here when we're looking at 20 microsconds per division where the spikes on here are actually going above the TTL minimum high level If I look at uh glu over a slightly longer time here of 500 microsconds per division then we can see that in fact these spikes are occurring above the 2V level at quite regular intervals and it's about um 2 kHz 2,000 times a second This was obviously causing trouble and what I did was I was checking the register values uh on and outputting these on the logic analyzer and from time to time they were getting zero for some reason and this was changing the UR from using 8 bits no par to 5 bits no par which certainly messed things up a bit and this is the high value So you can see that uh this is the zero volts here and this is the high value And what I ended up doing is all I've done is reused one of the unused pins on the decoder the LD And all I'm doing is taking the active low reset signal and inverting it in fact for use on the local board here It seems that the active low signal doesn't seem to suffer from the same interference issues that the active high one does And so this is now what the reset looks like So I've called it X reset And so this is the same parameters as we had on the one showing the repeating spikes there And in fact if I then toggle it between the preset we've got now versus what it was you'll see that it's really quite a big difference So these are just one of the sort of things particularly the stripboard bus seems to be picking up a certain amount of interference So it's something I'll need to look into But by fixing that then the thing has now actually running fairly reliably And the other test I was just going to do is I've got one of the test programs that I was using some of the earlier videos The LED key test version 3 was the one that I used in some of the earlier videos where we're getting the display and the keypad to work And all I've done is I've updated this slightly so that I can load it into the memory at about 700 0 segment and I've just modified it slightly so that it will run in that area won't interfere with the monitor and all this is doing is putting nano comp on the display showing some values for testing out these two left segment right segment routines and then what it will then do is to highlight write the key code for each of the keys that it press So I just wanted something that I could output down the serial port just to make sure that everything was working Okay And when we assemble this you'll see here the file type here is S record rather than binary So for brem we normally use binary but for the serial port we'll use srecord And the srec file for this particular program is here So you'll see here the if you look on each line data bytes here about 64 So there's about 32 bytes of data here So we got our S1 the number of bytes on the line the address that it's going to be loaded at That's four hexodimal digits for the address Then in this case we've got 32 hexodimal bytes here And then we've got the check sum on the end And then at the end we've got our S9 which basically says this is the end of the file All we need to do here is to copy this on clipboard All I'm going to do is to use the realterm send function here So you can see we can just send a file So I'm just going to go down onto the nano comp and we'll go into load So that's the finish So all we need to do now is we're going to set the extra segment to 7 0 0 and we'll also set the code segment to 700 0 as well So when we come to run it it should run Okay So now I'm going to hit load And so it will just sit there waiting for me to send the file So I'll just send the file And that has finished That's okay And all I'm going to do is just do go 0000 We got nano comp We've got the test pattern We've got our 89 tof Another test pattern And now if I press the buttons it will show the key code So you'll see the key code sort of uh go across the keypad So that indicates that the download is working The saving appears to be working I'm going to do some more testing on it but uh it looks like those side of things are working Okay so I've got the serial port working though The reset issue did take quite a while to resolve and it's only after I put the oscilloscope on some of the lines that I saw these spikes and things So it's always worthwhile having something like an oscilloscope You don't need to use it all the time but there are those occasions where everything else has failed that the oscilloscope actually picked up a particular problem So that's all I was going to do for this video So we've now completed our Nano for AT88 So we now have everything on the left hand side here working We're able to use a serial port using a PC compatible serial port and the SR file for the loading and saving is working as well In the next series of videos we're going to be looking at what makes a computer IBM PC compatible which we've looked at in the previous series And in particular we're going to be looking at adding the power on self test port and some of the port B which is used to configure things like the faster clock speed turbo mode And then we'll be building out the interrupt controller speaker timer real-time clock and getting the BIOS up and running And the reasons having these things at the top here is that the BIOS goes through initializes all of these things at the beginning And so if we don't have these set up then the BIOS won't really be able to get any further And then we're going to be looking at building out the text modes of the CGI video controller getting a PS2 keyboard controller as well the floppy disc controller and then hopefully we'll then be able to boot MS DOS from the floppy disc And then after that we'll be looking at adding hard disks booting MSTOS from hard disks adding all of the graphics modes to the CGI video controller adding a mouse and then running Windows 1 2 and 3 like we did in the first series So thanks for watching If you don't want to miss out on future videos then please hit subscribe And if you hit like as well just helps to make the videos available to more people

2025-03-31 10:35

Show Video

Other news

David Schmidt, Dell Technologies | Is Your IT Infrastructure Ready for the Age of AI? 2025-04-12 11:08
Markets Whipsaw on Uncertainty, Apple Might Hike Prices | Bloomberg Technology 2025-04-10 00:51
NAB Preview: PYXIS 12K, Strada Agents, Gaussian Splats and More 2025-04-07 22:11