|
|
View previous topic :: View next topic |
Author |
Message |
coin
Joined: 30 Apr 2010 Posts: 2
|
Parallel flash and parallel master port |
Posted: Tue May 04, 2010 1:27 am |
|
|
Hi, I am using PIC24FJ256GB110 and MX29LV160DT parallel flash.
Flash is connected to PIC trough Parallel Master Port what is described in application note 1210 using fully multiplexed mode.
Lines Q0-Q7, CE#, OE#, WE#, A-1, PMALL and PMALH are connected to PIC's PMP lines. A16-A19 is connected to GND (in this moment I am not interested for upper part, just 64K). #RESET is connected to Vcc. WP# and BYTE# is connected to GND.
With this code I want to read manufacturer ID (C2 for this memory) but I have no results. I tried all combinations of configuration through PMCON. Every time answer is FF or 00. Where I'm wrong?
Code: |
#include "pmode.h"
// define UART
#pin_select U1TX=PIN_G6
#pin_select U1RX=PIN_G7
#use rs232(UART1,baud=9600,parity=N,bits=8)
// define PMP mem interface
#word PMCON= 0x0600
#word PMMODE= 0x0602
#word PMADDR= 0x0604
#byte PMDOUT1= 0x0604
#byte PMDOUT2= 0x0606
#byte PMDIN1= 0x0608
#byte PMDIN2= 0x060A
#word PMAEN= 0x060C
#word PMSTAT= 0x060E
void PMPInit(void)
{
PMMODE = 0x0200; //Select Master mode with Read & Write on 2 separate pins
PMAEN = 0x8003; //Enable PMCS2 port
PMCON = 0x9360; //
}
void set_ports(void)
{
set_tris_d(0xF8C0); // A17, A18, A19, A-1
set_tris_f(0xFEFB); // BYTE, A16
delay_ms(2);
}
char MemByteRead(unsigned long Address)
{
unsigned int Temp;
while(PMMODE & 0x8000); //wait till PMP is busy
PMADDR = Address; //load Address to PMADDR
PMADDR |= 0x8000;
Temp = PMDIN1; //do a dummy read to initialize the read
while(PMMODE & 0x8000); //wait till PMP is busy
return(PMDIN1); //return the data read
}// end MemByteRead
void MemByteWrite(unsigned long Address, unsigned char Data)
{
while(PMMODE & 0x8000); //wait till PMP is busy
PMADDR = Address; //load Address to PMADDR
PMADDR |= 0x8000;
while(PMMODE & 0x8000); //wait till PMP is busy
PMDIN1 = Data; //write the Data
}//end MemByteWrite
unsigned char manufacturer_id(void)
{
unsigned char tmp;
MemByteWrite (0x0AAA, 0xAA);
MemByteWrite (0x0555, 0x55);
MemByteWrite (0x0AAA, 0x90);
tmp = MemByteRead(0x0000);
return tmp;
}
void main()
{
setup_spi( FALSE );
setup_spi2( FALSE );
setup_wdt(WDT_OFF);
setup_timer1(TMR_DISABLED|TMR_DIV_BY_1);
set_ports();
putc('A'); // just to indicate start of program
PMPInit();
putc(manufacturer_id());
for(;;);
} |
|
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Wed May 05, 2010 3:45 pm |
|
|
It's not completely clear to me, how you connected each Flash address line. If I understand right, you connected Pin "A-1" to
the PMBE port. But in byte mode of the device (#BYTE = L), A-1 is the lowest address line, so according to the "fully multiplexed"
scheme, it must be connected to the address latch LSB pin, I think. The other address pins are effectively shifted by one, pin "A0"
is the second address bit and so on. |
|
|
coin
Joined: 30 Apr 2010 Posts: 2
|
|
Posted: Thu May 06, 2010 2:02 am |
|
|
Thank you FvM for reply.
This board come to me finished, i cannot make modifications now.
Connection is fully multiplexed and table is:
Q0 - Q7 : E0 - E7
CE# : D10
OE# : D5
WE# : D4
WP# : D1
BYTE# : F2
RESET# : D2
RY/BY# : D12
A16 : F0
A17 : D0
A18 : D11
A19 : D9
A-1 : D3
PMALL : B15
PMALH : B14
So, this is good connection to PMP. Now i see that A-1 is address LSB in byte mode, so i will try 16 bit data. Thank's again. |
|
|
|
|
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 vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|