NEED HELP WITH MC6821

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

NEED HELP WITH MC6821

3,143 Views
drummerboy
Contributor I
I make military spare and repair parts.   One old item uses the MC6821.  I have been trying my best to understand how this **bleep** thing gets addressed and the app's sheets are written as narrative like a text book for those who already know how to use it..... which makes it valueless to me.

     What I need to do is very simple for test purposes only.   I need to make both of the  ports outputs and then write a square wave into them at about 1 second rate.

 

    I have an ATE system that I can use to set up data lines and write pulses and the like.   I just have no experience in using the MC6821.    Is there anyone who can give me the a simple explanation like... put this word on the data bus, pulse the enable, then put this on the data bus, pulse the enable, and so on so I can use the ATE to generate the square waves I need.   I can do all the ATE programming, but this MC6821 has me stumped on how to use it.                       H E L P    M E  ....  S O M E B O D Y

Labels (1)
0 Kudos
6 Replies

1,038 Views
donw
Contributor IV

hi

It was a pity that Moto never gave a simple explantion of how to setup the 6821 PIA IC.


for each port It has two addresses, a control/status reg & a 'peripheral/ddr' reg.

It is not complicated. The problem is that they never gave a clear, unique Name to 'peripheral/ddr register', so it seems confusing.

 

For the 'peripheral/DDR' reg, the device has effectively two registers:

- a peripheral register used to read/write data to the port

 -a data direction register to configure each port bits to input or output. 

 

The trick is that both registers share the same address, To access the DDR reg. you have to clear a bit (d3) in the Control reg.

So the sequence is:

write d3 = 0 to control reg. (to select the DDR reg)

write to DDR reg your port direction bit pattern

write d3=1 to control reg (to select port data reg)

write/read to peripheral reg (to  ports  )

don

 

 

 

0 Kudos

1,038 Views
donw
Contributor IV
sorry: use bit d2 not d3 in the control reg. 
0 Kudos

1,038 Views
drummerboy
Contributor I

     I do appreciate that you took the time to respond.   I think I need to make myself clearer than I had before.   I am almost exclusively involved with small microcontrollers like the Microchip PIC series and the Intel line like the older 8085 structures.    I have NEVER used a PIA before.

    When you saythings like "write a 0D to the control register" it is virtually meaningless to me because I don't know the proceedure.   This is a very confusing chip for the novice to pick up.    I've been doing micro's for quite a while, but this data sheet stuff is written as if one plumber is telling another plumber how to install a sink.    Both plumbers pretty much know how to do it already.    I need someone to help me as if the plumber was telling a shoe salesman how to install a sink.

    I there a way for anyone to write simple instructions like;

1- put [0d] on the data bus

2- pulse the [e] line

3- put [14] on the data bus

4- pulse the [e] line

 

and so on.      What I want to do is simply make both ports output ports.  I need to then succeccively write all 1's and then all 0's to both ports.    THAT'S IT!

 

I have no familiarity with, or access to any motorola 6800 equipment, but my ATE can create any 8 bit word I need and any kind of positive/negative pulses and address lines you tell me to create.

 

I feel like such an A-Hole because I've beeen going over the data sheet again and again, and I can't grasp how you address different registers that have the same address.

 

When I finally see how it's done I know I'll feel even worse, but my back is against the wall because I have to ship this controller board to the U.S. Army, and my time is just about all gone.

                 Can someone please help me.  

0 Kudos

1,038 Views
donw
Contributor IV

Since you are emulating all the uP control lines with your ATE device, you have some work to do!

Check out the data sheet for a micro such as mc6802.

Or Look at bus timing diagrams fig 1 of PIA data sheet:

to get a byte to the PIA:

tie unneed cs1, cs2 to suitable levels

set E line high, /WR line high

 

take /cs0 high  to deselect the ic 

setup the data bus data,

then take the E line low 

then set PIA's two reg. select lines [ RS0,1]  to select the correct reg.

then take the  PIA's /cs  low

pulse /WR line low/high to latch out data

take E high

take /cs0 high

 

This is all from my (old) memory, so check the timing diagrams!

 


So the sequence is:

write d2 = 0 to control reg. (to select the DDR reg)

write to DDR reg your port direction bit pattern (FF for all outputs)

write d2=1 (04) to control reg (to select port data reg)

write/read to peripheral reg (data to  ports  )

don

0 Kudos

1,038 Views
drummerboy
Contributor I

Don;

            I feel like such a retard.   I know I'm missing something here.

 

you sent me:

 

So the sequence is:

write d2 = 0 to control reg. (to select the DDR reg)

write to DDR reg your port direction bit pattern (FF for all outputs)

write d2=1 (04) to control reg (to select port data reg)

write/read to peripheral reg (data to  ports  )

don

 

     If nothing changes, who can you write d2 =0 and then a port direction pattern.  If all the selects are the same, how can the unit tell where anyting goes?     See... I'm missing something.

     I know I'm being a pain, but maybe one more little piece of info can get me over the hump.    No wonder they don't use this thing anymore....Is there a Capt. Zoom decoder ring I can buy somewhere that clear this thing up?

 

Steve

 

0 Kudos

1,038 Views
donw
Contributor IV

bit d2 in the reg. is a hardware toggle bit, that allows either the direction reg. or

the data reg.  to be accessed from the same address. 

on RESET itd2=0 so the direction reg. is accessed (since you would normally want to setup

the port direction bits first!), after which you need t0 set d2= 1 so the port reg. is accessed

for port data  access .

 

0 Kudos