Still working on Smart Card sample.
karlprescott
Posts: 15
Hi Guys,
I am working on the Smart Card demo (24c16 Demo). I am able to read data from the card but I am having trouble understanding the Write principle.
" sc.writeLocation(CLK, DeviceAddr | (((page) - 1) << 1) & 10, MAddr, char) "
I just get random data on the card when I change different values in the code.
Is their any one out there who fully understands it? I have looked at Jon Macs demo (jm_sc32322_Demo) and read both the Smart Card and Card Reader documentation and still dont get it.
Thanks for reading!
Karl
I am working on the Smart Card demo (24c16 Demo). I am able to read data from the card but I am having trouble understanding the Write principle.
" sc.writeLocation(CLK, DeviceAddr | (((page) - 1) << 1) & 10, MAddr, char) "
I just get random data on the card when I change different values in the code.
Is their any one out there who fully understands it? I have looked at Jon Macs demo (jm_sc32322_Demo) and read both the Smart Card and Card Reader documentation and still dont get it.
Thanks for reading!
Karl
Comments
This is the working code from my object:
What you're not seeing is that the EEPROM is setup as multiple blocks (documentation: http://ww1.microchip.com/downloads/en/devicedoc/21703g.pdf); the block derived from the address you want to write to and moved into the slave id. Each block is 256 bytes (bits 7..0 in the address) so the block number you want to access is held in bits 8 and higher. The reason my code only slides the bits over by 7 (instead of 8) is that bit0 of the SlaveID is for read/write control.
Think of the address this way: %000_00000000. The upper three bits are the block #, the lower eight bits are the address within that block.
I have to admit, this is a first. Most people just want to know where an object is and couldn't give two hoots about how it works. Good on you for wanting to know.
Ive read that document you sent me and it make the process of writing easier to understand.
I am using IS24C02_16A.spin as my object and that uses the writeLocation object. writeLocation(CLK, DeviceAddress, Register, Value)
Can a decimal number (0-254) just be sent to a speciafic location say Page 0 Word Address 01?
Got it working.. When I looked at your code it started working perfectly. Its the sample that paralax supply for the card that was giving me garbage. Wish I has looked at your code sooner.
Thanks Karl :-)