Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Multiplexed address/data bus on pic18F

Status
Not open for further replies.

jboud

Newbie level 6
Joined
Dec 25, 2008
Messages
11
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,355
input_d

Hi all,
I use port D to multiplex add/data to control a modem (mfrc531)
and here is my read function:

unsigned char read (unsigned char add)

{ unsigned char val;

SET_TRIS_D( 0x00 );
output_d(add); // Send address
delay_cycles(1);
output_high(ALE);
delay_cycles(1);
output_low(ALE);
delay_us(3);
output_low(NRD);
SET_TRIS_D( 0xFF );
delay_us(3);
val=input_d(); // receive data
delay_cycles(1);
output_high(NRD);
delay_cycles(1);

return val;
}



the problem is that val takes the address value which i sent previsiouly.

I can't find the problem.

I would really appreciate receiving your help.

Cordially
 

pic18f4550 portd not working

Hi all,
I use port D to multiplex add/data to control a modem (mfrc531)
and here is my read function:

unsigned char read (unsigned char add)

{ unsigned char val;

SET_TRIS_D( 0x00 );
output_d(add); // Send address
delay_cycles(1);
output_high(ALE);
delay_cycles(1);
output_low(ALE);
delay_us(3);
output_low(NRD);
SET_TRIS_D( 0xFF );
delay_us(3);
val=input_d(); // receive data
delay_cycles(1);
output_high(NRD);
delay_cycles(1);

return val;
}



the problem is that val takes the address value which i sent previsiouly.

I can't find the problem.

I would really appreciate receiving your help.

Cordially
 

pic18f452 portd latd

This is most likely a timing issue. You will have to experiment to find the optimum delays between calls. Try increasing the delay befor the port read.

What is the code in the statements?
output_d(add);
val=input_d();

Are these functions or macros?

It would be better to write
LATD = add;
val = PORTD;

to avoid the overhead of a function call if these are functions.

If they are macros, dont use them. Macros have been depreciated as they obscure the understanding of the code and are nothing but string substitutions.
 

    jboud

    Points: 2
    Helpful Answer Positive Rating
latch not working pic18f

Thank you for the reply.

output_d(add) and val=input_d() are functions provided by the ccs compiler.
We can't access to their corps.

I will try

LATD = add;
val = PORTD;

and i will keep you informed

cordially
 

multiplexed address/data bus

Hi jboud

It looks like you may be reading the port LATCH and not the port PINS
- check your generated assembly code is reading register 0xF83 (PORTD)

I suggest that the TRISD 0xFF is placed BEFORE the Negative Read Strobe (NRD)

You may well have a problem with bus contention.

The PROTECTED data sheet of the MFRC531, that you have had problems unlocking, states that the data lines will be asserted within 65ns of the leading negative edge of the read strobe NRD.

At max clock the 18F452 takes 100ns per instruction - releasing the bus (trisd 0xff) after asserting the strobe is too late!

As I read the timings - most of your delays could be removed as they are unnecessary with the 18F452 at 40MHz.

hope this helps - Polymath
 

    jboud

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top