PIC Modules for Emulation
- BitWise
- In Memoriam
- Posts: 996
- Joined: 02 Mar 2004
- Location: Berkshire, UK
- Contact:
PIC Modules for Emulation
I found some pre-built USB modules that use the same PIC device I was planning to use for my 65C02 emulator.
http://www.robot-electronics.co.uk/acat ... dules.html
You could easily simulate any 8-bit CPU with 64K of RAM on the same module (6502, 6800, 6809. 1802, 8080, Z80). I've ordered a couple to save me having to do any SMT soldering. All it needs is a base board with a MAX3232 and an SD card socket.
The PIC32 (MIPS) module would be faster but is extremely tricky to program in anything other than C.
http://www.robot-electronics.co.uk/acat ... dules.html
You could easily simulate any 8-bit CPU with 64K of RAM on the same module (6502, 6800, 6809. 1802, 8080, Z80). I've ordered a couple to save me having to do any SMT soldering. All it needs is a base board with a MAX3232 and an SD card socket.
The PIC32 (MIPS) module would be faster but is extremely tricky to program in anything other than C.
Andrew Jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs
Looks good - 30 pounds plus postage gets you a 50-pin DIL module with 16bit cpu and 96k RAM.
The MAX2323 should be optional I think - the USB can act as a COM port connection to a host.
(If programming in C isn't an obstacle, or if ARM rather than PIC is your thing, this cheap fast dev board by ST might look attractive. ChuckT found it.)
Cheers
Ed
The MAX2323 should be optional I think - the USB can act as a COM port connection to a host.
(If programming in C isn't an obstacle, or if ARM rather than PIC is your thing, this cheap fast dev board by ST might look attractive. ChuckT found it.)
Cheers
Ed
- BitWise
- In Memoriam
- Posts: 996
- Joined: 02 Mar 2004
- Location: Berkshire, UK
- Contact:
USB drivers are not easy to write. The protocol responses have to be exactly right for the host driver to operate correctly and there isn't a generic CDC driver built into Windows as there is for other USB device classes. A simple UART connection is the easiest way to get started then I can use that to debug a dual channel CDC (one for the emulated device and one for the debugger)
Programming in C isn't a problem, it's just that I prefer bare metal coding. The ARM boards are nice but I'd need to retool to use them. I don't have a JTAG programmer.
Programming in C isn't a problem, it's just that I prefer bare metal coding. The ARM boards are nice but I'd need to retool to use them. I don't have a JTAG programmer.
Andrew Jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs
I don't think there'd be any need to write a driver on the host side - there wasn't with the i2c adapter board I bought (from the same company.) Anyhow, you'll soon be able to find out, if the boards are on their way.
But perhaps I'm missing something, if there's a need to run a debugger over the USB port at the same time. I saw that there's an example program to exchange data over the USB to the PIC, so that seemed hopeful.
Cheers
Ed
But perhaps I'm missing something, if there's a need to run a debugger over the USB port at the same time. I saw that there's an example program to exchange data over the USB to the PIC, so that seemed hopeful.
Cheers
Ed
- BitWise
- In Memoriam
- Posts: 996
- Joined: 02 Mar 2004
- Location: Berkshire, UK
- Contact:
BigEd wrote:
I don't think there'd be any need to write a driver on the host side - there wasn't with the i2c adapter board I bought (from the same company.) Anyhow, you'll soon be able to find out, if the boards are on their way.
But perhaps I'm missing something, if there's a need to run a debugger over the USB port at the same time. I saw that there's an example program to exchange data over the USB to the PIC, so that seemed hopeful.
Cheers
Ed
But perhaps I'm missing something, if there's a need to run a debugger over the USB port at the same time. I saw that there's an example program to exchange data over the USB to the PIC, so that seemed hopeful.
Cheers
Ed
Windows contains a generic driver that allows any HID (mouse or keyboard) or disk class device to be attached without any Windows drivers but there is not a generic CDC (serial, modem) driver. Microchip provide one for thier devices which you customise with sepecfic vendor and product identifiers (VID/PID) for your application.
I want expose my emulator as two USB based COM ports, one connected to the control interface of the emulator, the other viewed as a 6551 peripherial by the code being emulated. That way you can use one terminal to debug and one to view application output.
Having a real UART on the device will make debugging the USB code much easier during development. I can use it to dump the command packets back to a PC. If I had the cash I'd buy a USB protocol analyzer but they are a bit pricey.
No sign of the modules in the post yet.
Andrew Jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs
-
ElEctric_EyE
- Posts: 3260
- Joined: 02 Mar 2009
- Location: OH, USA
BitWise wrote:
... Microchip provide one for thier devices which you customise with sepecfic vendor and product identifiers (VID/PID) for your application...
- BitWise
- In Memoriam
- Posts: 996
- Joined: 02 Mar 2004
- Location: Berkshire, UK
- Contact:
My modules arrived last night so now I have no excuse not to make a start on the USB firmware (other than all the other projects I have, the software I'm supposed to be updating for my own company and the uncertainty at my day job caused by someone losing 2.3bn Euro - very careless of them)
Andrew Jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs
- BitWise
- In Memoriam
- Posts: 996
- Joined: 02 Mar 2004
- Location: Berkshire, UK
- Contact:
I built a simple carrier for the module to hold the RS232 transceiver and drilled/filed some suitable holes in a ABS project box to hold the project.



First job is to get the module working with the serial connection. Then i can start with the USB interface and virtual serial ports.



First job is to get the module working with the serial connection. Then i can start with the USB interface and virtual serial ports.
Andrew Jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs
- BitWise
- In Memoriam
- Posts: 996
- Joined: 02 Mar 2004
- Location: Berkshire, UK
- Contact:
It lives ...

Trace output generated via the UART

Trace output generated via the UART
Andrew Jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs
Re: PIC Modules for Emulation
Andrew (BitWise),
Did you publish this project (and source code) somewhere?
Cheerful regards, Mike
Did you publish this project (and source code) somewhere?
Cheerful regards, Mike
- BitWise
- In Memoriam
- Posts: 996
- Joined: 02 Mar 2004
- Location: Berkshire, UK
- Contact:
Re: PIC Modules for Emulation
Michael wrote:
Andrew (BitWise),
Did you publish this project (and source code) somewhere?
Cheerful regards, Mike
Did you publish this project (and source code) somewhere?
Cheerful regards, Mike
Andrew Jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs
- BitWise
- In Memoriam
- Posts: 996
- Joined: 02 Mar 2004
- Location: Berkshire, UK
- Contact:
Re: PIC Modules for Emulation
I've ported the code to a different device in the PIC24 family, added support for interrupts and a few bug fixes. I found some nice Arduino shield shaped PCBs with a bread board style layout on ebay for my latest prototype. The UART is connected to the usual Arduino RXD/TXD pins (lower right corner) so I will be able to stack my terminal shield on the top to add a display and keyboard.
The only components needed to make this work are two decoupling capacitor, a tantalum for the core voltage regulator and a pull up resistor on the reset - Two more resistors are needed for the ICSP programmer. I'm using the internal fast RC oscillator and the PLL to increase the speed to 70MIPs.
At the moment I'm using a USB CDC adapter to connect it to my laptop. I've written an emulation of key parts of Acorn MOS 1.20 so that I can get BBC BASIC working. This device only has 8K of RAM so the recursive part of the bench test does not work yet - I'm waiting for a chip that will allow 16K of RAM to be delivered and later in the year there will be a device that will support 32K.
The results from the bench test so far are:
The emulator supports all the 65C02 instructions and has a fully functioning decimal mode. Interrupts are trapped by the host and passed to the emulation for handling. Currently I'm only using a 100Hz timer interrupt but I will be adding a UART RX handler.
I use the 65C816 opcode (COP $02) to access the host processor. I currently have six functions (get last interrupt source, read memory, write memory, bit set, bit clear, get RAM size). You can see how these are used in the MOS listing.
All the unused I/O pins are available for use. Some changes are needed to the firmware to enable peripherals and select the pins that they will use.
At the moment I'm using a USB CDC adapter to connect it to my laptop. I've written an emulation of key parts of Acorn MOS 1.20 so that I can get BBC BASIC working. This device only has 8K of RAM so the recursive part of the bench test does not work yet - I'm waiting for a chip that will allow 16K of RAM to be delivered and later in the year there will be a device that will support 32K.
The results from the bench test so far are:
Code: Select all
>RUN
BBC BASIC CPU Timing Program
Real REPEAT loop Speed: 5.16MHz
Integer REPEAT loop Speed: 5.21MHz
Real FOR loop Speed: 5.36MHz
Integer FOR loop Speed: 5.23MHz
Floating-Point Test Speed: 5.99MHz
Ackermann Recursion
No room at line 180
>
I use the 65C816 opcode (COP $02) to access the host processor. I currently have six functions (get last interrupt source, read memory, write memory, bit set, bit clear, get RAM size). You can see how these are used in the MOS listing.
All the unused I/O pins are available for use. Some changes are needed to the firmware to enable peripherals and select the pins that they will use.
- Attachments
-
- mos.zip
- MOS Listing
- (10.82 KiB) Downloaded 505 times
Andrew Jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs
- BitWise
- In Memoriam
- Posts: 996
- Joined: 02 Mar 2004
- Location: Berkshire, UK
- Contact:
Re: PIC Modules for Emulation
Optimized the flag handling a bit more
Code: Select all
>RUN
BBC BASIC CPU Timing Program
Real REPEAT loop Speed: 5.51MHz
Integer REPEAT loop Speed: 5.58MHz
Real FOR loop Speed: 5.66MHz
Integer FOR loop Speed: 5.74MHz
Floating-Point Test Speed: 6.33MHzAndrew Jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs