I have played around and got the Saving Working 100%, (I only tried it on a Mifare Card with the First Digit of 3 so I have not completed the full code yet), I can write and view the Saved Serial number perfectly but I can't seem to read it back!, its driving me nuts, something in the Get_Data Macro is not right
In Get_Data() the eeprom::Read probably needs to return to B0[idx] not idx
Although in Main you have B0=Get_Data(0)
So you either need to write to a separate global buffer within Get_Data()
or write to a local string, then return it from Get_Data()
but again, probably not to B0 as you use that elsewhere.
I can't seem to get anything to Display of the LCD, I have tried for around 3 hours with different ways and perhaps I should have a break as I am seeing things double, would you have a sample?
Hi Gavin,
I've done a demo of the EEPROM read and write, attached. You could re-use the macros.
Press F1 or F2 to write a string, press OK to read that stored string.
Regarding your program, there is some confusion between global variables and local variables and parameters of the macros.
And some have the same names.
Inside a macro when you use any local variables, or parameters of the macro, these need to start with a dot.
So if you pass the StartAddress then inside the macro you access that with .StartAddress
Otherwise if you use StartAddress without the dot, you are actually reading the global variable StartAddress.
This is why it is better to use different names, then you don't get the wrong one in error.
The EEPROM device of the dsPIC uses Channel 2 (not Channel 1),
looks like a bug might have crept into our code there, as I thought this was automatically set,
something for me to look into.
Got the . for local parameters and variables, makes sense (still learning..)
I have tried the Demo program attached and for some reason I cannot read the saved string back?, its just blank. I can see Store F1 and F2 when I press the buttons but when I press 4 (OK), its blank and then I cannot go back and press F1 or F2 again, do you think my Miac is faulty?
Hi Gavin,
I suggest you upgrade to Flowcode 8.1
Then the component auto-updates will be active again.
Not sure if it will fix your problem, but I think this is a valid first step
Leigh
Only issue is that it only saves data from the tag starting with a "3", if the "3" is second the data is not Saved its just blank. I assumed we were saving the string B0 regardless of where the 3 is?
I have attached a series of Pic's from the MIAC, reading Mifare Card one I get to see the serial# and also confirm the "Save data" serial number that is has "saved the data" and also when I hold the "OK" button in after the UART Read I can see the saved data as well on the last line of the display. I am also able to read back the serial # on its own by pressing the "OK" button at any time. Works 100% - no issues
On Card 2 the number "3" is the second digit, I read the whole string back perfectly and also confirm B0 as the saved data on the second line of the display. When I keep holding in the "OK" button I can also see the value after the UART read, however when I try and read the saved serial number back on its own I can't seem to display any read data, I can only read the data back when the first digit is a "3",
Card 1 read back.jpg (104.01 KiB) Viewed 14639 times
Card 1 Confirm Save.jpg (107.15 KiB) Viewed 14639 times
Card 1 Confirm + Hold OK.jpg (104.16 KiB) Viewed 14639 times
I think the strings are getting crossed data.
You might need to have more than one buffer/string (i.e. don't use B0 for everything, such as UART receive and EEPROM read)
In particular:
1) If you are going to display the EEPROM read within Get_Data,
you don't need to place the return value into B0 (when you call Get_Data in Main)
as that is then going to be used as the input to your "If BO[x] = '3'" tests (and cause a re-write into EEPROM)
2) After your call to UART1::ReceiveString() you first need to check if BO[0] = 0
If it does, then a new string has not been received.
Only if it is non-zero do you then need go into testing for the existence of '3' in any of the locations.
Ok I think I have found out why I am not seeing the data, B0[0]works 100%, B[1]and the rest looks like it keeps going back to into a loop, that is why I can read it when I hold the OK button down for the first time, if I release the OK button it keeps running back to B1[1] (and others as [B2], [B3] etc) as if there is a Mi-fare card, same as point 2 in your message below, I assume the saved data it is overwritten with blank spaces?,
Only question I have is why would it do that?, do you have a suggestion on a better way to detect the "3" can I rather use an array?, would you have an example?