Author Topic: Self-Programming the MC68701 and the MC68701U4? (motorola)  (Read 19959 times)

0 Members and 1 Guest are viewing this topic.

Offline bytestormTopic starter

  • Regular Contributor
  • *
  • Posts: 64
  • Country: se
Self-Programming the MC68701 and the MC68701U4? (motorola)
« on: January 29, 2019, 12:06:29 pm »
Hey!

Since the document titled "Self-Programming the MC68701 and the MC68701U4" Motorola. Part: AN906A seems to have become Unobtainium, I thought Id ask here..
(I have even emailed Motorola directly about it)

I need to program a couple of MC68701U4 with a supplied bin file, but I cant find any programmer that handles them.. or they do, but need some unobtainable adapters.
Programming is however described in the datasheet but I would rather avoid constructing a programmer for it, if there is a simpler way.. (would love learn how to make one with the help of maybe a ARM or AVR but aint got time now.. )

Anyone have any idea where I could find this document? Or perhaps knows how to program these ones?

Datasheet:
http://matthieu.benoit.free.fr/cross/data_sheets/MC68701U4.pdf

Thanks in advance!
« Last Edit: January 29, 2019, 12:19:42 pm by bytestorm »
 

Offline amyk

  • Super Contributor
  • ***
  • Posts: 8318
Re: Self-Programming the MC68701 and the MC68701U4? (motorola)
« Reply #1 on: January 29, 2019, 01:20:44 pm »
Note that Motorola is now NXP so perhaps asking them might yield better result.
 

Offline bytestormTopic starter

  • Regular Contributor
  • *
  • Posts: 64
  • Country: se
Re: Self-Programming the MC68701 and the MC68701U4? (motorola)
« Reply #2 on: January 29, 2019, 01:54:19 pm »
Note that Motorola is now NXP so perhaps asking them might yield better result.

Yeah, already tried. :( they even started a case for it but didnt find anything ;(
 

Online joeqsmith

  • Super Contributor
  • ***
  • Posts: 11894
  • Country: us
Re: Self-Programming the MC68701 and the MC68701U4? (motorola)
« Reply #3 on: January 29, 2019, 01:58:02 pm »
I suspect I have everything you would ever want to know about the 01.  If no one else turns it up, I'll post that section of the document later.   

I designed a bit of test gear around one for the fun of it.  Scan down, you can see one of the programmers I made for it.
https://www.eevblog.com/forum/testgear/hear-kitty-kitty-kitty-nope-not-that-kind-of-cat/350/

Online joeqsmith

  • Super Contributor
  • ***
  • Posts: 11894
  • Country: us
Re: Self-Programming the MC68701 and the MC68701U4? (motorola)
« Reply #4 on: January 29, 2019, 02:47:09 pm »
Hitachi did make a few CMOS clones of the Motorola parts for a short time.  Their databooks are on-line.  I suspect they will show the basics how to program them but maybe not for your specific part.  It will at least give you some idea what is required while I find the original notes.


https://www.jaapsch.net/psion/pdffiles/hd6301-3_handbook.pdf

Offline Circlotron

  • Super Contributor
  • ***
  • Posts: 3213
  • Country: au
Re: Self-Programming the MC68701 and the MC68701U4? (motorola)
« Reply #5 on: January 29, 2019, 10:26:09 pm »
I remember seeing that technique with HC705 series. Have a look at some of those data sheets or other notes. Might be similar enough in principle to get you going.
 

Online joeqsmith

  • Super Contributor
  • ***
  • Posts: 11894
  • Country: us
Re: Self-Programming the MC68701 and the MC68701U4? (motorola)
« Reply #6 on: January 30, 2019, 02:50:43 am »
Enjoy

Offline amyk

  • Super Contributor
  • ***
  • Posts: 8318
Re: Self-Programming the MC68701 and the MC68701U4? (motorola)
« Reply #7 on: January 30, 2019, 02:54:31 am »
These MCUs are programmed basically by running a program from external memory, which then manipulates the internal registers so as to write to the EPROM. This means they can only be "self-programmed".

Here's a (newer?) datasheet on the MC68701 with a more detailed description of the programming algorithm (including source code) as well as the elusive test mode 4: http://pdf.dzsc.com/autoupload/4cbea484-a30f-4eab-a2e8-224414b2d8b3.pdf

This is the "PRObug" ROM monitor that also implements the programming algorithm along with other useful commands:
 http://www.chookfest.net/computers/files/probug.s19
 
The following users thanked this post: edavid

Offline bytestormTopic starter

  • Regular Contributor
  • *
  • Posts: 64
  • Country: se
Re: Self-Programming the MC68701 and the MC68701U4? (motorola)
« Reply #8 on: January 30, 2019, 06:53:00 am »
Wow thousand thanks for all replies! I will dig into all this later today! The PRObug rom will most certainly help since I could not find it and the manual stated that it was needed.. phew!
Thank you all!! :D
 

Offline bytestormTopic starter

  • Regular Contributor
  • *
  • Posts: 64
  • Country: se
Re: Self-Programming the MC68701 and the MC68701U4? (motorola)
« Reply #9 on: January 31, 2019, 04:35:49 pm »
oh my.. that was alot of info :). Lots of it is concerning the regular 68701, and not the 68701U4 that I have, but that might be since they are very similar?
I found some more info about this whole programming board and schematics for the APB board for 68701, and I hope that its possible to modify it for the 4Kb eprom in the "U4" compared to the 2k in the regular 68701.

I wonder why they made it so darn complicated to program? :).. or maybe its not that difficult, but the instructions are a bit vague.. like the part that you need an external program (probug) to program the internal eprom... but where do I put the code I have that is supposed to be programmed? the 4kb bin file that I am hoping to program into the 68701u4.. :) ??

I will check the book with the schematics tonight for some clarification. If some one is interested, it starts from page 204 in this book!
https://ia800205.us.archive.org/0/items/Motorola-SeminarsandApplicationBooksMCUandMPUApplicationsManualOCR/Motorola-SeminarsandApplicationBooksMCUandMPUApplicationsManualOCR.pdf

would love to find a newer copy since there is a possibility that newer versions would cover the 68701u4 specifics maybe.

Thanks again all!! and please give your comments if any.

 

Offline amyk

  • Super Contributor
  • ***
  • Posts: 8318
Re: Self-Programming the MC68701 and the MC68701U4? (motorola)
« Reply #10 on: February 01, 2019, 03:10:59 am »
The U4 is very similar to the non-U4, just with more memory.

It is up to you how you get the code to it, the point is that the MCU will run code from external RAM/ROM, and you can make it run code that programs its EPROM. It could accept bytes from the serial port, one of the parallel ports, or even just read from some other memory mapped into the external address space (including the code to do the programming itself!)
 

Offline bytestormTopic starter

  • Regular Contributor
  • *
  • Posts: 64
  • Country: se
Re: Self-Programming the MC68701 and the MC68701U4? (motorola)
« Reply #11 on: February 04, 2019, 07:00:54 am »
The U4 is very similar to the non-U4, just with more memory.

It is up to you how you get the code to it, the point is that the MCU will run code from external RAM/ROM, and you can make it run code that programs its EPROM. It could accept bytes from the serial port, one of the parallel ports, or even just read from some other memory mapped into the external address space (including the code to do the programming itself!)

I was hoping to find some clear info about when it actually starts programming itself. There are lots of info about putting it into different modes and such, but its unclear to me when it actually starts to read the data and program its own eprom section with it.. I just cant seem to understand how the data will be sent to it.

Perhapps i will have options in the PRObug terminal window when its actually running?

The best would be if it was able to program itself from a set memory space in a external eprom, into its own eprom area.. but I cant see how that process would be "started"

is it me or is the process explained vaguely in the book? :(

Thanks!
 

Offline grantb5

  • Regular Contributor
  • *
  • Posts: 139
  • Country: ca
Re: Self-Programming the MC68701 and the MC68701U4? (motorola)
« Reply #12 on: February 04, 2019, 02:10:45 pm »
I've used the 68705P3 before and it's pretty well documented on the web. Maybe there are some ideas or hints there? I don't know your part but it sounds like an EPROM version of the 6801, is that right? I think I have some old databooks that cover this era somewhere. And there were always pretty much second sources back then so a "competitor" databook might help as well. I haven't been able to find my MC68705P3 hardware ... hmmm...
 

Online joeqsmith

  • Super Contributor
  • ***
  • Posts: 11894
  • Country: us
Re: Self-Programming the MC68701 and the MC68701U4? (motorola)
« Reply #13 on: February 05, 2019, 05:11:14 am »
The U4 is very similar to the non-U4, just with more memory.

It is up to you how you get the code to it, the point is that the MCU will run code from external RAM/ROM, and you can make it run code that programs its EPROM. It could accept bytes from the serial port, one of the parallel ports, or even just read from some other memory mapped into the external address space (including the code to do the programming itself!)

I was hoping to find some clear info about when it actually starts programming itself. There are lots of info about putting it into different modes and such, but its unclear to me when it actually starts to read the data and program its own eprom section with it.. I just cant seem to understand how the data will be sent to it.

Perhapps i will have options in the PRObug terminal window when its actually running?

The best would be if it was able to program itself from a set memory space in a external eprom, into its own eprom area.. but I cant see how that process would be "started"

is it me or is the process explained vaguely in the book? :(

Thanks!
What you are suggesting with the external EPROM is basically how it's normally done.   I thought the source code was fairly simple to follow.  Mine is a bit more fancy with an LCD display.   I started with that and modified it.  The software resides in an external EPROM in my case.  I am using a dual ported memory to emulate a PROM which gets plugged into my standard EPROM programmer.  Once the dual port memory is programmed with the image, I load it into the 01.   Still the idea is the same.   I assume you read those pages I collected for you. 

Why do you need to program these old devices?  Just curious what would even be using them today.   
 
The following users thanked this post: bytestorm

Offline bytestormTopic starter

  • Regular Contributor
  • *
  • Posts: 64
  • Country: se
Re: Self-Programming the MC68701 and the MC68701U4? (motorola)
« Reply #14 on: February 05, 2019, 06:37:06 am »


Thanks!
[/quote]
What you are suggesting with the external EPROM is basically how it's normally done.   I thought the source code was fairly simple to follow.  Mine is a bit more fancy with an LCD display.   I started with that and modified it.  The software resides in an external EPROM in my case.  I am using a dual ported memory to emulate a PROM which gets plugged into my standard EPROM programmer.  Once the dual port memory is programmed with the image, I load it into the 01.   Still the idea is the same.   I assume you read those pages I collected for you. 

Why do you need to program these old devices?  Just curious what would even be using them today.
[/quote]

Yes I have read the source you sent me several times but I cant seem to get it :/. I have never worked with this types before..
I understand how to make reads and writes to simple sram and flash/eproms, but I cant get my head around this one :(.

In which external memory space would I put the PRObug? And if I could have my 4k code in a area at the same time, which would that be?

Sorry for all these noob questions that probably are really simple once you understand, but right now its a bit messy for me.

I want to replace a MCU in an arcade game :)

Thanks for your time
 

Online joeqsmith

  • Super Contributor
  • ***
  • Posts: 11894
  • Country: us
Re: Self-Programming the MC68701 and the MC68701U4? (motorola)
« Reply #15 on: February 05, 2019, 01:14:31 pm »
Yes I have read the source you sent me several times but I cant seem to get it :/. I have never worked with this types before..
I understand how to make reads and writes to simple sram and flash/eproms, but I cant get my head around this one :(.

In which external memory space would I put the PRObug? And if I could have my 4k code in a area at the same time, which would that be?

Sorry for all these noob questions that probably are really simple once you understand, but right now its a bit messy for me.

I want to replace a MCU in an arcade game :)

Thanks for your time

You know, if you have a micro you like, you could perhaps make an adapter to drive the game with a new micro.   The 01 was a workhorse of the industry in it's time but doesn't have much going for it compared with the lowest end modern micros.  Ditch the assembler code.   

Figure E-4 shows the memory map.   Section E.4 explains the process.   Looking at the assembler listing, 00078A  ORG $3000  where is states "EPROM STARTS HERE"  is where they have mapped this code.  From Fig E-4, we can see $3000 fall between $00FF and $BFF0 which marked "External Memory Space".    Of course, we can see in E.2.2 that the vectors are remapped for Mode 0.  Obviously they need to be or we wouldn't have access to set them.  If it's not clear, the external EPROM will contain these vectors.  Reset for example will need to point to your main section of code.   

Something like:
INTVEC    EQU  $BFF0          VECTOR TABLE

INVALID_IRQ    RTI            EXIT

          ORG  INTVEC
          FDB  INVALID_IRQ
          FDB  INVALID_IRQ
          FDB  INVALID_IRQ
          FDB  INVALID_IRQ
          FDB  INVALID_IRQ
          FDB  INVALID_IRQ
          FDB  INVALID_IRQ
          FDB  RESET           
          END

Where RESET is the pointer to your startup code.

The routine in the listing is called from your main program.   The header in the listing explains what you need to pass to it when making the call.   Figure E-4 shows the internal EPROM residing at $F800.  This is obviously for the 2K device and you would need to change this for the 4K device to $4000.   

It's not too difficult really.  6800 has a fair number of instructions.  Do you have the tools needed to build the code?  Assembler, linker and such? 

Offline bytestormTopic starter

  • Regular Contributor
  • *
  • Posts: 64
  • Country: se
Re: Self-Programming the MC68701 and the MC68701U4? (motorola)
« Reply #16 on: February 06, 2019, 06:22:23 am »

You know, if you have a micro you like, you could perhaps make an adapter to drive the game with a new micro.   The 01 was a workhorse of the industry in it's time but doesn't have much going for it compared with the lowest end modern micros.  Ditch the assembler code.   

Figure E-4 shows the memory map.   Section E.4 explains the process.   Looking at the assembler listing, 00078A  ORG $3000  where is states "EPROM STARTS HERE"  is where they have mapped this code.  From Fig E-4, we can see $3000 fall between $00FF and $BFF0 which marked "External Memory Space".    Of course, we can see in E.2.2 that the vectors are remapped for Mode 0.  Obviously they need to be or we wouldn't have access to set them.  If it's not clear, the external EPROM will contain these vectors.  Reset for example will need to point to your main section of code.   

Something like:
INTVEC    EQU  $BFF0          VECTOR TABLE

INVALID_IRQ    RTI            EXIT

          ORG  INTVEC
          FDB  INVALID_IRQ
          FDB  INVALID_IRQ
          FDB  INVALID_IRQ
          FDB  INVALID_IRQ
          FDB  INVALID_IRQ
          FDB  INVALID_IRQ
          FDB  INVALID_IRQ
          FDB  RESET           
          END

Where RESET is the pointer to your startup code.

The routine in the listing is called from your main program.   The header in the listing explains what you need to pass to it when making the call.   Figure E-4 shows the internal EPROM residing at $F800.  This is obviously for the 2K device and you would need to change this for the 4K device to $4000.   

It's not too difficult really.  6800 has a fair number of instructions.  Do you have the tools needed to build the code?  Assembler, linker and such?

mm.. best would be to implement it into verilog and us a fpga (or micro).. would be awesome but skillwise I am faaar from that.. I have some dev boards but to make a 6801u4 in verilog would be way over my head. To use a micro on the other hand would require me to dissassemble the 4k binary I have and somehow implement that into a micro..

since I dont have the source, only the compiled 4k bin for the 68701u4, I might be in bigger trouble than I anticipated :(

So the 68701 is actually not programmed like I originally thought.. It actually needs the source asm code, and not the actual compiled binary? then I would need to somehow dissassemble the 4k binary and put that into the codesnippet..

aaah... I need to re-read the manuals and docs. Its quite frustrating reading the text that abviously explains it in detail, and dont "getting" how it works :D

 

Offline amyk

  • Super Contributor
  • ***
  • Posts: 8318
Re: Self-Programming the MC68701 and the MC68701U4? (motorola)
« Reply #17 on: February 06, 2019, 12:55:38 pm »
I think you're very confused about how the programming process works.

These MCUs can run code from external or internal memory.

Programming the EPROM is accomplished by running code that manipulates registers on the MCU which control the EPROM.

If you boot it from an external memory, then you can make it run the code you want, code which programs the EPROM.
 

Online joeqsmith

  • Super Contributor
  • ***
  • Posts: 11894
  • Country: us
Re: Self-Programming the MC68701 and the MC68701U4? (motorola)
« Reply #18 on: February 06, 2019, 12:57:44 pm »
If you are writing the code to perform the programming of the internal memory, you will need the tools.   

You don't need to disassemble the arcade game's binary and rebuild it just to program the part.   

My comment about replacing the 01 was suggesting you write your own software from scratch for the arcade game using a different micro.  I am not suggesting that you would disassemble the binary you have and port it.  That's a bit too boring. 

If you have the full schematics and assembled code, you would be all set.  Obviously, that's not what I sent you.   I haven't looked through any of the other posts but maybe they have what you need.  In my case, I just went with the notes, wrote my own code and built the hardware.

Another option as I showed in that link is to try and find an old Hitachi part.  Maybe you could find another game with the micro preloaded with what you want.

Offline bytestormTopic starter

  • Regular Contributor
  • *
  • Posts: 64
  • Country: se
Re: Self-Programming the MC68701 and the MC68701U4? (motorola)
« Reply #19 on: February 06, 2019, 06:18:08 pm »
I think you're very confused about how the programming process works.
Yes, that is absolutely correct :)

These MCUs can run code from external or internal memory.
Yes I know.

Programming the EPROM is accomplished by running code that manipulates registers on the MCU which control the EPROM.
Yes, I know this too.. :)

If you boot it from an external memory, then you can make it run the code you want, code which programs the EPROM.
This is where I am lost.. I dont understand HOW to run "my code" or where to put it and how to make it start the programming process so that my 4k binary actually gets into the eprom.

This is where I fail to follow somehow :(..

I need my 68701u4, set to mode 0, make it start run the code in the PRObug eprom, which needs to contain "my code" somehow, or if PRObug needs to direct yet another eprom containing "my code" to get that 3rd one to somehow get the code into the epromarea................. or something. I havent had time to reread the docs again, but I will asap.

the more I try to understand to further away from actually understanding it I get :/.

To make a micro behave exactly like this MCU then I would need a full understanding of what the compiled program actually do? (which I dont, since I only have the binary.)

Sigh.. maybe this was a bad idea from the start.. aint got no linker or assembler tool either. Was just hoping it would be easy to get that darn 4k bin file into the eprom area :(


 

Offline grantb5

  • Regular Contributor
  • *
  • Posts: 139
  • Country: ca
Re: Self-Programming the MC68701 and the MC68701U4? (motorola)
« Reply #20 on: February 06, 2019, 06:39:35 pm »
I think the manufacturer information is out there. This datasheet explains self programming at the end:

http://pdf.datasheetcatalog.com/datasheets2/46/4637908_1.pdf

Here is another snippet.

https://www.edaboard.com/showthread.php?258453-how-to-copy-motorola-s-MC68701-mcu

Apologies if this is known already.
 
The following users thanked this post: bytestorm

Online joeqsmith

  • Super Contributor
  • ***
  • Posts: 11894
  • Country: us
Re: Self-Programming the MC68701 and the MC68701U4? (motorola)
« Reply #21 on: February 07, 2019, 12:43:59 am »
It may help to know what level of education do you have?  Do you have any formal education with embedded designs?  Background?   If this is your first look at assembler and you have never built anything with a microcontroller, it would make sense what you are describing and perhaps we can try to simplify things for you. 

I am sure I could supply you with the tools you would need to assemble the code if you decide to write your own programming software.   I have never used the canned tool that was linked but you may be able to find a manual for it that would explain how it needs to be mapped.   

Quote
This is where I am lost.. I dont understand HOW to run "my code" or where to put it and how to make it start the programming process so that my 4k binary actually gets into the eprom.

This is where I fail to follow somehow :(..

As I mentioned, your code is pointed to by the reset vector.  When you reset the micro, it will start to run your program.   Once the device is programmed, the mode is changed and the reset vector will now point to the arcade game's code.  The mode pins are the key....   

Offline bytestormTopic starter

  • Regular Contributor
  • *
  • Posts: 64
  • Country: se
Re: Self-Programming the MC68701 and the MC68701U4? (motorola)
« Reply #22 on: February 07, 2019, 06:28:22 am »
It may help to know what level of education do you have?  Do you have any formal education with embedded designs?  Background?   If this is your first look at assembler and you have never built anything with a microcontroller, it would make sense what you are describing and perhaps we can try to simplify things for you. 

I am sure I could supply you with the tools you would need to assemble the code if you decide to write your own programming software.   I have never used the canned tool that was linked but you may be able to find a manual for it that would explain how it needs to be mapped.   

As I mentioned, your code is pointed to by the reset vector.  When you reset the micro, it will start to run your program.   Once the device is programmed, the mode is changed and the reset vector will now point to the arcade game's code.  The mode pins are the key....

I have no formal education with embedded designs, just used some smaller avr for simple projects, for example to read and write to/from memories and sram, and displaying the data at the given adress on a small display. (in C++). I had hoped to get away with some similar simple bitbanging.
No experience with assembler, apart from the lessons described here: http://www.z80.info/lesson1.htm but never really worked with it.

From the schematics in the book on the other hand I can design the PCB and make it, no problem.
 

Online joeqsmith

  • Super Contributor
  • ***
  • Posts: 11894
  • Country: us
Re: Self-Programming the MC68701 and the MC68701U4? (motorola)
« Reply #23 on: February 07, 2019, 12:50:54 pm »
This helps.  I wonder in your case if there is a company who offers programming them as a service.  It sounds like it's a one time deal anyway and to be honest, I really don't see where learning about the 01 is going to help you going forward.  It's just such old technology. 

Do you ow understand the mode selection, vector tables and how they are used to run the programs?

Offline bytestormTopic starter

  • Regular Contributor
  • *
  • Posts: 64
  • Country: se
Re: Self-Programming the MC68701 and the MC68701U4? (motorola)
« Reply #24 on: February 07, 2019, 01:53:04 pm »
This helps.  I wonder in your case if there is a company who offers programming them as a service.  It sounds like it's a one time deal anyway and to be honest, I really don't see where learning about the 01 is going to help you going forward.  It's just such old technology. 

Do you ow understand the mode selection, vector tables and how they are used to run the programs?

I hoped to be able to solve this since its 10 units I want to program.. but in worst case. (probably would cost more than I am willing to spend thou..)

I understand the mode selection, but when it fetches a "vector table" I am not so sure what that means.

This below is the instructions straight from the datasheet

When the MC68701U4 is released from reset in mode 0, a
vector is fetched from location $BFFE:$BFFF.

- So it fetches a vector (instruction?) from those 2 adresses? or all inside that area?

This provides
a method for an external program to obtain control of the
microcomputer with access to every location in the EPROM.

- Ok, so here it must mean that now PRObug can somehow interact with the MCU? (or viceversa)

To program the EPROM, it is necessary to operate the
MC68701 U4 in mode 0 under the control of a program resident
in external memory which can facilitate loading and programming
of the EPROM.

- Allright, this must be PRObug? But how can the external memory controll the MCU?

After the pattern has been loaded
into external memory, the EPROM can be programmed as
follows:

- Ok.. what pattern is getting loaded into what external memory? (sram i suppose)
- Is it here "my code" would get loaded into a external sram? If so, from where does it get loaded into external sram?

a. Apply programming power (VPP) to the RESET/Vpp
pin.

- ok (haha jeez, well atleast I can probably get this one right).

b. Clear the PLC control bit and set the PPC bit by writing
$FE to the RAM/EPROM control register.

- ok, how would I do that? (cant possibly mean manually right? since its for every single byte..)

c. Write data to the next EPROM location to be programmed.
Triggered by an MPU write to the EPROM, internal
latches capture both the EPROM address and the
data byte.

- Now here I dont see what I am supposed to do. How am I supposed to write data?
- Or does it simply mean that it WILL write the data if I trigger a MPU write manually somehow?

d. Clear the PPC bit for programming time, tpp, by writing
$FC to the RAM/EPROM control register and waiting
for time, tpp. This step gates the programming power
(Vpp) from the RESETlVpp pin to the EPROM which
programs the location.

- ok, how would I do that? (cant possibly mean manually right? since its for every single byte..)

e. Repeat steps b through d for each byte to be programmed.
- Will the counter increment automatically?

f. Set the PLC and PPC bits by writing $FF to the
RAM/EPROM control register.

- How would I do that?

g. Remove the programming power (Vpp) from the
RESET IVpp pin. The EPROM can now be read and
verified.

- ok

As you can see there are many points where I cant see how its suposed to be done. :/

« Last Edit: February 07, 2019, 01:56:25 pm by bytestorm »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf