6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Nov 23, 2024 8:53 am

All times are UTC




Post new topic Reply to topic  [ 298 posts ]  Go to page Previous  1 ... 9, 10, 11, 12, 13, 14, 15 ... 20  Next
Author Message
PostPosted: Sun Mar 15, 2020 3:00 pm 
Offline
User avatar

Joined: Fri Aug 03, 2018 8:52 am
Posts: 746
Location: Germany
Chromatix wrote:
You should be very careful about separating the power planes of the USB interface and the rest of the board. If the USB chip drives a high logic level into any logic whose power is not only removed but grounded, you can expect that signal to short through the protection diodes of whatever logic is connected to it. Does the USB chip interpret its selection signals as active-low?


the USB chip doesn't have any select lines, only 2 inputs for RD and WR, 8 data lines, and 2 "flags" of sorts, which are active low and connected to the 3 state buffer at the bottom left of the board.

hmm, so would it be better to leave the power lines floating instead? or just have the whole thing shut down when the power switch is off


Top
 Profile  
Reply with quote  
PostPosted: Sun Mar 15, 2020 5:05 pm 
Offline

Joined: Mon May 21, 2018 8:09 pm
Posts: 1462
Okay, if RD and WR are active-high, then the chip will be deselected by powering down the logic driving them. This should ensure the 8 data lines are tri-stated.

The flag lines are then the principal concern. If either of them are pulled high for any reason, that will be seen at the inputs of the tri-state buffer.


Top
 Profile  
Reply with quote  
PostPosted: Sun Mar 15, 2020 5:19 pm 
Offline
User avatar

Joined: Fri Aug 03, 2018 8:52 am
Posts: 746
Location: Germany
Chromatix wrote:
Okay, if RD and WR are active-high, then the chip will be deselected by powering down the logic driving them. This should ensure the 8 data lines are tri-stated.

The flag lines are then the principal concern. If either of them are pulled high for any reason, that will be seen at the inputs of the tri-state buffer.


well the RD line is active low while the WR is active high.

I could just pull the RD line high to Vcc without the switch being on, to ensure it's high.
same with the tri state buffer's OE lines.

but then the question is what's with the GALs that these lines come from?

I think it would just be easier to have the whole thing shut down when the switch is off.
or alternativly just not have anything to do with power and just hold the RESET line low for as long as it's on... nah, i think powering the whole down would be the best option.


Top
 Profile  
Reply with quote  
PostPosted: Sun Mar 15, 2020 8:29 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
Proxy wrote:
Chromatix wrote:
Okay, if RD and WR are active-high, then the chip will be deselected by powering down the logic driving them. This should ensure the 8 data lines are tri-stated.

The flag lines are then the principal concern. If either of them are pulled high for any reason, that will be seen at the inputs of the tri-state buffer.


well the RD line is active low while the WR is active high.

I had a look at the datasheet
https://www.ftdichip.com/Support/Docume ... FT240X.pdf
and was mildly surprised: both RD# and WR are pulses, or strobes. If I've read it right, it's the trailing edge of the low-going RD# or the high-going WR which commit the access.


Top
 Profile  
Reply with quote  
PostPosted: Mon Mar 16, 2020 6:49 pm 
Offline
User avatar

Joined: Fri Aug 03, 2018 8:52 am
Posts: 746
Location: Germany
ok just to make sure because i'm about to order the new batch of PCBs, when the power switch is off all Vcc connections are connected through a resistor to ground... and that shouldn't cause any problems, right?
so not even the USB chip stays active everything is disconnected from the power input (ie the USB Port's Vcc pin)
the only reason i wanted it to stay active in the first place was so that the COM Port wouldn't disappear from the Task Manager and Terminal programs, which would've been a bit helpful, but is not necessary.

BigEd wrote:
I had a look at the datasheet
https://www.ftdichip.com/Support/Docume ... FT240X.pdf
and was mildly surprised: both RD# and WR are pulses, or strobes. If I've read it right, it's the trailing edge of the low-going RD# or the high-going WR which commit the access.


Write is a simple strobe yes, it latches the data on the falling edge of the WR signal.
but RD will output the data for as long as the RD signal stays low. unless i'm reading the datasheet wrong. because T1 (RD# Active Pulse Width) only has a minimum time, not a maximum.


Top
 Profile  
Reply with quote  
PostPosted: Fri Mar 20, 2020 6:22 pm 
Offline
User avatar

Joined: Fri Aug 03, 2018 8:52 am
Posts: 746
Location: Germany
ok i actually found a mistake i made with the Reset line on my PCB. fixed that and now it should be ready to ship.

though i also wanted to play around with the ATF1504, but since i never worked with it i don't want it directly on my SBC...
instead i want to design and order some "smart" breakout boards. with smart meaning that all imporant pins are kina grouped together (like GND and Vcc lines) instead of it just being a straight PLCC to DIP adapter.
but i'm already running into issues with this chip, for example some of the pins don't seem to be explained anywhere, like the Global Clocks (GCLK), Global Reset? (GCLR), PD, and EO. are they optional pins? should i use a or all Global Clock pins when using the PH2 clock for decoding? etc.
another thing: it never really mentions what type of JTAG connector it uses. it just mentions the 4 signals required.
I'm almost sure it's the 10 pin JTAG type, but the pinouts i find online are kinda inconstant, they often switch the sides of the pins, but then again that shouldn't matter because i can just rotate the connector. but it would still be nice to know exactly how it should be on the PCB.
a second problem is the fact that i need a programmer, i really don't want to spend 50 bucks on an offical one unless i have to. (I'm cheap)
I checked Ebay to find some, and came across these things: LINK
20 bucks, JTAG, but it says Lattice instead of Atmel so i'm not sure...

I also thought about getting this USB Blaster, which isn't compatible with the ATF1504, but with the MAXII CPLD i also wanted to play around with. it has more IO Pins, a lot more Macrocells, and is around the same price as the ATF1504, only downside it's 3.3V logic so it requires some input voltage shifting in order to connect it to the CPU's Address/Control lines. the outputs shouldn't matter as any 5V device should see 3.3V as a logic High.

anyways besides that i've been programming around a bit with my current board since it still is a functional computer.
and my confusion about the 65c02's Flags continue as i recently got a "Get String" function complete...
aparently i don't understand the Zero flag, i thought it would be set when the output of an arithmetic/logic instruction is equal to 0. but aparently not.
I have a simple loop in my "Get String" function that checks if there is data inside the FT240X, by constantly checking the status pins of the chip.
If there is no data to read bit 1 of the byte is "1", if there is data to read that bit is "0"
here is my loop (the wrong one):
Code:
.WAIT_RX:            ; Check if there is data available in the FIFO
   LDA STT           ; Load from the STaTus Register
   AND 0b00000010    ; Mask out all bits except bit 1 and check if it's 0
BNE .WAIT_RX         ; if it's not, jump back to the start

my idea was the following:
This is the input data when there is no data to read: 0bxxxxxx1x (x = don't care)
so if you AND this by 0b00000010 the output should be: 0b00000010, right?
but for some reason that sets the Zero flag, so it doesn't do the BNE instruction and just continues with the rest of the function....
but why?

.

sorry for the loaded post


Top
 Profile  
Reply with quote  
PostPosted: Fri Mar 20, 2020 6:39 pm 
Offline

Joined: Fri Apr 15, 2016 1:03 am
Posts: 140
Your understanding of the Z flag seems correct.

Looking at your assembly code:
Is the "AND 0b00000010" assembling to the immediate AND (0x29 0x02) or the zero-page AND (0x25 0x02) or the absolute AND (0x2d 0x02 0x00)?
In Z80 assembler, it's the difference between "AND A,0b00000010" and "AND A,(0b00000010)".
6502 assembler usually looks like "AND #0b00000010" for immediate and "AND 0b00000010" for zero-page or absolute.


Top
 Profile  
Reply with quote  
PostPosted: Fri Mar 20, 2020 7:34 pm 
Offline
User avatar

Joined: Fri Aug 03, 2018 8:52 am
Posts: 746
Location: Germany
leepivonka wrote:
Your understanding of the Z flag seems correct.

Looking at your assembly code:
Is the "AND 0b00000010" assembling to the immediate AND (0x29 0x02) or the zero-page AND (0x25 0x02) or the absolute AND (0x2d 0x02 0x00)?
In Z80 assembler, it's the difference between "AND A,0b00000010" and "AND A,(0b00000010)".
6502 assembler usually looks like "AND #0b00000010" for immediate and "AND 0b00000010" for zero-page or absolute.


i converted the code from my usual Z80 style to 6502 style to make it easier to read... but i forgot some symbols...
it's an immediate value.

here the format in my Z80 style:
0x00 = Immediate
[0x00] = Zero-Page
(0x0000) = Absolute

technically i could change it to automatically use the Zero Page when the absolute address is less than 0x0100.
CustomASM is actually able of doing stuff like that, and i did do it for the Classic 6502 style, but for some reason i didn't for this one...


Top
 Profile  
Reply with quote  
PostPosted: Fri Mar 20, 2020 8:02 pm 
Offline
User avatar

Joined: Tue Mar 05, 2013 4:31 am
Posts: 1385
Proxy wrote:
I have a simple loop in my "Get String" function that checks if there is data inside the FT240X, by constantly checking the status pins of the chip.
If there is no data to read bit 1 of the byte is "1", if there is data to read that bit is "0"
here is my loop (the wrong one):
Code:
.WAIT_RX:            ; Check if there is data available in the FIFO
   LDA STT           ; Load from the STaTus Register
   AND 0b00000010    ; Mask out all bits except bit 1 and check if it's 0
BNE .WAIT_RX         ; if it's not, jump back to the start

my idea was the following:
This is the input data when there is no data to read: 0bxxxxxx1x (x = don't care)
so if you AND this by 0b00000010 the output should be: 0b00000010, right?
but for some reason that sets the Zero flag, so it doesn't do the BNE instruction and just continues with the rest of the function....
but why?

.

sorry for the loaded post



Also, when testing single bits in something like a status register, the BIT instruction can be helpful as it can change flags without changing the contents of the accumulator. Here's a small chunk of code from my BIOS which supports a NXP UART:

Code:
INTERUPT0       LDA     UART_ISR        ;Get the UART Interrupt Status Register (4)
                CMP     #%00100000      ;Check for no active IRQ source (2)
                BEQ     REGEXT0         ;If no bits are set, exit handler (2/3)
;
                BIT     #%00001000      ;Test for Delta Break (2)
                BNE     UART_BRK        ;If yes, Reset the UART receiver (2/3)
                BIT     #%00000100      ;Test for RHR having data (2)
                BNE     UART_RCV        ;If yes, put the data in the buffer (2/3)
                BIT     #%00000001      ;Test for THR ready to receive data (2)
                BNE     UART_XMT        ;If yes, get data from buffer (2/3)
                BIT     #%00010000      ;Test for Counter ready (RTC) (2)
                BNE     UART_RTC        ;If yes, go increment RTC variables (2/3)
;
IRQEXT0         STA     UART_IRT        ;Else, save the 2691 IRT for later use (4)
                LDA     UART_STATUS     ;Get 2691 Status Register (4)
BUFF_ERR        STA     UART_SRT        ;Save 2691 Status Register for later use (4)
REGEXT0         JMP     (IRQRTVEC0)     ;Return to Exit/ROM IRQ handler (6)
;

_________________
Regards, KM
https://github.com/floobydust


Top
 Profile  
Reply with quote  
PostPosted: Sat Mar 21, 2020 1:06 am 
Offline
User avatar

Joined: Sat Dec 01, 2018 1:53 pm
Posts: 730
Location: Tokyo, Japan
Proxy wrote:
here the format in my Z80 style:
0x00 = Immediate
[0x00] = Zero-Page
(0x0000) = Absolute

That's a bit confusing, becuase in standard 65C02 syntax, LDA ($00) loads the contents of what $0000,$0001 is pointing to. Just to be totally clear:

Code:
0000            org $0000
0000: 34 12     dw  $1234

1234            org $1234
1234: 56        db  $56

7000            org $7000
7000: A9 00     lda #$00    ; loads #$00 into A
7002: B5 00     lda $00     ; loads #$12 into A
7004: B2 00     lda ($00)   ; Loads #$56 into A (65C02 only)
7006: A0 00     ldy #$00    ; index
7008: B1 00     lda ($00),Y ; loads #$56 into A (6502, 65C02)

So what syntax do you use for indirect loads through a pointer in zero page?

_________________
Curt J. Sampson - github.com/0cjs


Top
 Profile  
Reply with quote  
PostPosted: Sat Mar 21, 2020 5:35 am 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8508
Location: Midwestern USA
Proxy wrote:
here the format in my Z80 style:
0x00 = Immediate
[0x00] = Zero-Page
(0x0000) = Absolute

As said above, that's confusing. Put that in front of a long-time 6502 assembly language programmer and they'll be scratching their head.

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
PostPosted: Sat Mar 21, 2020 7:04 am 
Offline
User avatar

Joined: Fri Aug 03, 2018 8:52 am
Posts: 746
Location: Germany
cjs wrote:
That's a bit confusing, becuase in standard 65C02 syntax, LDA ($00) loads the contents of what $0000,$0001 is pointing to.

BigDumbDinosaur wrote:
As said above, that's confusing. Put that in front of a long-time 6502 assembly language programmer and they'll be scratching their head.


well that is just the standard Z80 syntax, only thing i added is the Zero page [] stuff. which as said i could technically remove with some changes to the Assembler. so you could imagine most of these with just () instead of [].
This is the reason i take my time to convert my Z80 Style code to 6502, as to not confuse you guys here.
personally i just find a lot better (because i started with the Z80) which is why i program with it at all...

cjs wrote:
So what syntax do you use for indirect loads through a pointer in zero page?


ok let me explain from the start so it makes sense what i'm about to show.
1. You load an immediate byte
2. you use that byte to load 2 values from Zero page
3. you use those 2 values as absolute address to load the final value from and into the A Register.
so in total it would become this:
1. Immediate byte: LD A, *
2. used for Zero-Page: LD A, [*]
3. and finally ABS Address: LD A, ([*])

same with the X and Y offset ones, where you just add X or Y to either step 2 or 3 to get:
LD A, ([*, X])
LD ([*], Y)

I know it's kinda convoluted but it makes sense to me, it's like math where you evaluate brackets away.
same with the Jump Indirect

a regular jump is just an Immediate value, so it would be something like:
JMP 0x8000
but an Indirect jump uses the 2 immedate bytes as an Absolute Adress to load the final values from
so, following the same logic as before it would be:
JMP (0x8000)


Top
 Profile  
Reply with quote  
PostPosted: Sat Mar 21, 2020 7:34 am 
Online
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8545
Location: Southern California
To add to the confusion, if you later decide to step up to the 65816, the square brackets are used to mean an indirect to a 24-bit address. For example, LDA (FOOBAR) will read two bytes in direct page to find out the final 16-bit address to read (in the current data bank), but LDA [FOOBAR] will read three bytes in direct page to find out the final 24-bit address to read (regardless of which data bank is the current one). The 65816 can address 16MB of memory map.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
PostPosted: Sat Mar 21, 2020 7:44 am 
Offline
User avatar

Joined: Fri Aug 03, 2018 8:52 am
Posts: 746
Location: Germany
GARTHWILSON wrote:
To add to the confusion, if you later decide to step up to the 65816, the square brackets are used to mean an indirect to a 24-bit address. For example, LDA (FOOBAR) will read two bytes in direct page to find out the final 16-bit address to read (in the current data bank), but LDA [FOOBAR] will read three bytes in direct page to find out the final 24-bit address to read (regardless of which data bank is the current one). The 65816 can address 16MB of memory map.


well luckly i never really wanted to use the 65816.
I've kinda made my own version of that CPU that i can throw on an FPGA.
which can also address 16MB of Memory but unlike the 65816 it doesn't deal with banks, it just has a 24 bit Program counter and overall deals with 24 bit addresses (excetp direct page stuff of course)
and i plan on using that CPU once i fiquire out how to wire up and program FPGAs on standalone boards.

speaking of which, i kinda want to focus back on the ATF1504 stuff. i know some of you have dealt with this chip before.
so i'd like to point back to the comment above about my confusion with it. like the pins, JTAG pinout, Programmer choice, etc.
(technically the MAX II as well)


Last edited by Proxy on Sat Mar 21, 2020 7:46 am, edited 1 time in total.

Top
 Profile  
Reply with quote  
PostPosted: Sat Mar 21, 2020 7:45 am 
Offline
User avatar

Joined: Sat Dec 01, 2018 1:53 pm
Posts: 730
Location: Tokyo, Japan
Proxy wrote:
well that is just the standard Z80 syntax....

Right. But something to keep in mind is that the Z80 doesn't have indirection through a pointer in memory, so LD A,(1234h) is unequivocal.

Quote:
...only thing i added is the Zero page [] stuff...

Ok, I think that you may be using the wrong terminology here and this may be creating some of the confusion. I think you don't mean the zero page addressing mode, but the indirect addressing mode, right? I.e., you're not differentating between (in traditional syntax) LDA $22 assembling to AD 22 00 (absolute) or A5 22 (zero page), both of which are valid assemblies, both of which have the same effect, and neither of which is indirect, right?

And I am guessing that when you said "ABS address" for LD A,([nnnn]) you really meant indirect address; in your syntax the 6502 absolute addressing mode, which indicates using the contents of a memory location (with no indirection) would be LD A,(nnnn), if I'm reading it right.

You may find it useful to look at this LDA instruction reference; it shows most of the addressing modes (missing only the "(Indirect)" mode, which exists only on the JMP instruction on non-CMOS 6502s.)

Assuming that's correct, I personally think it would be a good idea always to use 6502-style #-prefix for immediate, no prefix for absolute loads from memory (whether zero page or not), and brackets of some sort for indirect, and change your assembler to do that. While introducing LDA ([$1234]) or whatever probably isn't such a big deal, Making LDA ($1234) ambiguous seems destined to lead to problems and debugging when copying code around. (Remember that, though you chose square brackets for indirection, many 6502 assemblers use parentheses instead.)

Quote:
a regular jump is just an Immediate value, so it would be something like:
JMP 0x8000
but an Indirect jump uses the 2 immedate bytes as an Absolute Adress to load the final values from
so, following the same logic as before it would be:
JMP (0x8000)

Yeah, I think you've found an inconsistency there; if instead of JMP we had a LDPC instruction, it would make sense to write LDPC #$8000.

_________________
Curt J. Sampson - github.com/0cjs


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 298 posts ]  Go to page Previous  1 ... 9, 10, 11, 12, 13, 14, 15 ... 20  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 24 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: