|
|
View previous topic :: View next topic |
Author |
Message |
steve_st23
Joined: 09 Sep 2003 Posts: 6
|
MMC lock/unlock code problem |
Posted: Fri Apr 15, 2005 8:53 am |
|
|
I red from Sandisk Multimedia Card Product Manual Card Lock/Unlock Operation section i applicate what i read but it is not working, if anyone know how to do that procedure can explain to me step by step. |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Fri Apr 15, 2005 10:29 am |
|
|
I've read the chapter on locking/unlocking and think the explanation is very clear, even one of the better technical manuals I've seen. You are asking for a step by step description, well that's exactly what is in the book! What more detail do you want?
Maybe you should tell us what you are doing and we can tell you where the error is?
Just for our information, you are capable of writing data to and reading from the card? Or did you start your project by implementing the lock/unlock feature first?
Are you using SPI or MMC mode?
Which part isn't working? The setting or clearing of the password? |
|
|
steve_st23
Joined: 09 Sep 2003 Posts: 6
|
|
Posted: Sat Apr 16, 2005 2:11 am |
|
|
I have PRLLC's mmc codes for PIC MCU. Ican read, write, making folders etc. So I leave the lock/unlocking funtions to the last.
Quote: | � Set Password
The sequence for setting the password is as follows:
1. Select a card (CMD7), if not previously selected already.
2. Define the block length (CMD16), given by the 8bit card lock/unlock mode, the 8
bits password size (in bytes), and the number of bytes of the new password. In case
that a password replacement is done, then the block size shall consider that both
passwords, the old and the new one, are sent with the command.
3. Send Card Lock/Unlock command with the appropriate data block size on the data
line including 16-bit CRC. The data block shall indicate the mode (SET_PWD), the
length (PWD_LEN) and the password itself. In case that a password replacement is
done, then the length value (PWD_LEN) shall include both passwords, the old and
the new one, and the PWD field shall include the old password (currently used)
followed by the new password.
4. In case that the sent old password is not correct (not equal in size and content) then
LOCK_UNLOCK_FAILED error bit will be set in the status register and the old
password does not change. In case that PWD matches the sent old password then
the given new password and its size will be saved in the PWD and PWD_LEN
fields, respectively. Note that the password length register (PWD_LEN) indicates if
a password is currently set. When it equals �0� there is no password set. If the value
of PWD_LEN is not equal to zero the card will lock itself after power up. It is
possible to lock the card immediately in the current power session by setting the
LOCK/UNLOCK bit (while setting the password) or sending additional command
for card lock. |
I am using proteus simulation in real life in case of unlocking problem but the others functions are working very well. All my other functions are working in proteus simulation too. In simulation i can lock with password funtion but some how function is not work because unlock functions is not work too. Well my code is;
Code: |
void lock_mmc(void)
{
uHILO32 params;
int16 resp_r1;
params.cval.LO = 0xFF;
params.cval.ML = 0xFF;
params.cval.MH = 0x03; // password len
params.cval.HI = 0x01; // set pwd
resp_r1 = _SD_send_cmd(CMD16, 7); // Set block len
resp_r1 = _SD_send_cmd(CMD42, params.lval);
resp_r1 = _FF_spi('1'); // new password first character
resp_r1 = _FF_spi('2'); // new password second character
resp_r1 = _FF_spi('3'); // new password third character
resp_r1 = _FF_spi(0xFF); // checksum
resp_r1 = _FF_spi(0xFF); // checksum
}
|
|
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Sat Apr 16, 2005 7:17 am |
|
|
Try to get the official MMC v3.1 specification instead of the Sandisk manual, they are almost identical but I noticed the section of SPI-mode unlock has just two more sentences which might be helpful to you:
Quote: | 7.5.11 Card Lock/unlock
Usage of card lock and unlock commands in SPI mode is identical to MultiMediaCard mode. In both cases,
the command response is of type R1b. After the busy signal clears, the host should obtain the result of the
operation by issuing a GET_STATUS command. Please refer to Chapter 4.4.5 for details. |
The official MMC manual was free for download until about a year ago, then policies changed and now it is only available to members. Non-members can only download the v3.31 Table of Contents which is useless. Still, the complete v3.1 specification can be found on many other websites. Use Google with the exact keywords: "MultiMediaCard system specification" pdf
For example it is possible one of your previous locks succeeded? In that case your lock command will fail because it is already locked.
My suggestion is you try to figure out more details of your problem by checking the returned status info, i.e. after sending the lock command wait for the busy signal to clear, then use the GET_STATUS command to get the current status. This is good practice anyway because you want to make sure your lock was successful. |
|
|
|
|
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
|