6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Fri Nov 15, 2024 10:36 am

All times are UTC




Post new topic Reply to topic  [ 20 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: W65C165
PostPosted: Fri Jul 31, 2020 8:34 am 
Offline
User avatar

Joined: Tue Mar 02, 2004 8:55 am
Posts: 996
Location: Berkshire, UK
You need a python script (or its compiled windows exe) called emc_uploader_term.

The protocol is an extended version on the one used in other SXBs. They added some additional functions to write into the flash ROM area. The first 30K of the flash is copied into the upper RAM area ($8000-$F7FF) at boot then memory protected so looks like a ROM. If the 'WDC' signature is at $8000 then its executed from $8004.

I have been writing my own uploader in C# but its not complete. I've been too busy with other projects including trying to fix bugs in the WDC tool set which now crashes a lot less than it used to. Baby steps.

Yesterday I manged to build and run my first completely C application on the 165 which used the I2C peripheral to drive an SSD1306 OLED 128x32 display.

_________________
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


Top
 Profile  
Reply with quote  
 Post subject: Re: W65C165
PostPosted: Fri Jul 31, 2020 9:15 am 
Offline

Joined: Sat Jun 04, 2016 10:22 pm
Posts: 483
Location: Australia
Ideally, I'd just use that script, but it's supposed to be in WDCTools. The version I have(v2.1) doesn't have it, and I seem to be unable to get hold of a newer one.


Top
 Profile  
Reply with quote  
 Post subject: Re: W65C165
PostPosted: Fri Jul 31, 2020 10:37 pm 
Offline
User avatar

Joined: Tue Mar 02, 2004 8:55 am
Posts: 996
Location: Berkshire, UK
WDC sent me a revised prototyping board which has a real time clock, a flash memory and an encryption chip on it. I've been writing a peripheral library for the W65C165MMC and the other SXB boards. This is a photo of a test program using the RTCC and an I2C OLED display to create a simple clock.
Attachment:
image0.jpeg
image0.jpeg [ 767.4 KiB | Viewed 552 times ]

The library is mostly C based and compiles with the WDC C compiler I have been fixing. The library trades performance for portability. For example a my simple LED flashing test looks like this:
Code:
#include <system/w65c134sxb.h>

#define LED_PIN     pin50

void main (void)
{
    pinSetMode (&LED_PIN, OUTPUT);
    for (;;) {
        pinSetState (&LED_PIN, HIGH);
        delayMS (500);
        pinSetState (&LED_PIN, LOW);
        delayMS (500);
    }
}

If I moved the code to say the W65C02SXB and wanted to drive the LED from a VIA output then the only change would to include a different header <system/w65c02sxb.h> and alter the #define to reference a VIA pin object like 'via1_A0'.

When I have a bit more working and the updated compiler is released I will make the repository public.

_________________
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


Top
 Profile  
Reply with quote  
 Post subject: Re: W65C165
PostPosted: Sat Aug 15, 2020 6:04 am 
Offline

Joined: Sat Jun 04, 2016 10:22 pm
Posts: 483
Location: Australia
I've worked out the format the W65c165 uploader wants, that it calls Z-bin. WDC's linker outputs this, but it can be generated by just about anything using appropriate assembler directives. This format is also documented in the linker manual, found here, on page 37.
It's basically a header, imediately followed by the binary.
The header is as follows:
Code:
78 xx xx xx yy yy yy
 |  |  |  |  |  |  +- Length bank byte. I've only ever seen this as zero, but I don't have an '816-based board, which is where I assume this would be used.
 |  |  |  |  |  +---- Length high byte
 |  |  |  |  +------- Length low byte
 |  |  |  +---------- Start address bank byte
 |  |  +------------- Start address high byte
 |  +---------------- Start address low byte
 +------------------- Literal "Z"


Top
 Profile  
Reply with quote  
 Post subject: Re: W65C165
PostPosted: Sat Aug 15, 2020 12:11 pm 
Offline

Joined: Sat Jun 04, 2016 10:22 pm
Posts: 483
Location: Australia
I believe I've also found the SPI and I2C cores used in the '165, based on the sheer similarity in naming, structure, and register descriptions.
They can be found here: https://opencores.org/projects/simple_spi and here: https://opencores.org/projects/i2c/.
The documentation is here: [Link] and here: [Link].


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 20 posts ]  Go to page Previous  1, 2

All times are UTC


Who is online

Users browsing this forum: Martin A and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: