Page 1 of 2

EEPROM/FLASH dspMIAC

Posted: Mon Dec 17, 2018 5:10 pm
by gavo4
Hi All,

Hope all is well!,

How do I access the Flash of the dspMIAC?, I see the EEPROM has 0 bytes for the EESIZE,

Any help would be greatly appreciated...;-)

Regards,

Gavin

Re: EEPROM/FLASH dspMIAC

Posted: Mon Dec 17, 2018 6:25 pm
by Benj
Hi Gavin,

Please refer to this forum thread.

viewtopic.php?f=28&t=20175&p=88887#p88887

Re: EEPROM/FLASH dspMIAC

Posted: Tue Dec 18, 2018 2:33 pm
by gavo4
Thanks Benj!,

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

Any ideas which can help?..;-)

Code Attached,

Regards,

Gavin

Re: EEPROM/FLASH dspMIAC

Posted: Tue Dec 18, 2018 3:02 pm
by LeighM
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.

Re: EEPROM/FLASH dspMIAC

Posted: Tue Dec 18, 2018 6:37 pm
by gavo4
Hi Leigh,

Thanks for the response,

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?

Regards,

Gavin

Re: EEPROM/FLASH dspMIAC

Posted: Tue Dec 18, 2018 7:02 pm
by gavo4
My Latest Try attached....;-)

Re: EEPROM/FLASH dspMIAC

Posted: Wed Dec 19, 2018 9:16 am
by LeighM
I've made a few changes to DataIn and DataOut
not had chance to test it though

Re: EEPROM/FLASH dspMIAC

Posted: Wed Dec 19, 2018 10:35 am
by gavo4
Thanks Leigh!,

Will give it a go...;-)

Re: EEPROM/FLASH dspMIAC

Posted: Wed Dec 19, 2018 11:52 am
by gavo4
Hi Leigh,

It just says: Reading Flash when I press the OK Button (I assume it is sitting in the loop)

Regards,

Gavin

Re: EEPROM/FLASH dspMIAC

Posted: Wed Dec 19, 2018 12:50 pm
by LeighM
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.

Hope that all helps
Leigh

Re: EEPROM/FLASH dspMIAC

Posted: Wed Dec 19, 2018 1:14 pm
by gavo4
Thanks Leigh,

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?

Regards,

Gavin

Re: EEPROM/FLASH dspMIAC

Posted: Wed Dec 19, 2018 1:23 pm
by LeighM
Which version of Flowcode do you have?
Have you updated recently?

Also could you try turning on the Stop Delay ...
stop_delay.jpg
stop_delay.jpg (41.87 KiB) Viewed 10674 times

Re: EEPROM/FLASH dspMIAC

Posted: Wed Dec 19, 2018 1:35 pm
by gavo4
Hi Leigh,

8.0.0.6

Regards,

Gavin

Re: EEPROM/FLASH dspMIAC

Posted: Wed Dec 19, 2018 1:39 pm
by gavo4
This is what I have..

Re: EEPROM/FLASH dspMIAC

Posted: Wed Dec 19, 2018 1:48 pm
by gavo4
Hi Leigh,

I noticed my SDA and SCL Pins are different to yours?, perhaps that is why I am seeing no saved data?

Regards,

Gavin

Re: EEPROM/FLASH dspMIAC

Posted: Wed Dec 19, 2018 2:34 pm
by LeighM
Hi Gavin,
Yup, it sure won't help :?
Should be Channel 2, SDA port F.4, SCL port F.5
Leigh
ps. Chip View will help

Re: EEPROM/FLASH dspMIAC

Posted: Wed Dec 19, 2018 3:29 pm
by gavo4
Hi Leigh,

I have a ghost here - changed it but still the same - no receive data

Regards,

Gavin

Re: EEPROM/FLASH dspMIAC

Posted: Wed Dec 19, 2018 4:46 pm
by LeighM
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 :D
Leigh

Re: EEPROM/FLASH dspMIAC

Posted: Thu Dec 20, 2018 3:49 pm
by gavo4
Hi Leigh,

I have it working now - thanks for the help.

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?

Any help would be greatly appreciated,

Regards,

Gavin

Re: EEPROM/FLASH dspMIAC

Posted: Fri Dec 21, 2018 9:56 am
by LeighM
At the end of Get_Data you print the B0 string to the display, I think that should instead be LocalString that you have just read from EEPROM?

When you send the UART string that has a 3, but not in position 0, does it display on line 1?
If so, then it is being detected correctly.

Re: EEPROM/FLASH dspMIAC

Posted: Fri Dec 21, 2018 10:24 am
by gavo4
Hi Leigh,

I did try that and it did not work

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
Card 1 read back.jpg (104.01 KiB) Viewed 10633 times
Card 1 Confirm Save.jpg
Card 1 Confirm Save.jpg (107.15 KiB) Viewed 10633 times
Card 1 Confirm + Hold OK.jpg
Card 1 Confirm + Hold OK.jpg (104.16 KiB) Viewed 10633 times

Re: EEPROM/FLASH dspMIAC

Posted: Fri Dec 21, 2018 10:27 am
by gavo4
Card 2 data

Re: EEPROM/FLASH dspMIAC

Posted: Fri Dec 21, 2018 11:39 am
by LeighM
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.

Hope that helps
Leigh

Re: EEPROM/FLASH dspMIAC

Posted: Fri Dec 21, 2018 12:45 pm
by gavo4
Thanks Leigh,

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?

Regards,

Gavin

Re: EEPROM/FLASH dspMIAC

Posted: Fri Dec 21, 2018 1:04 pm
by LeighM
IFB0.jpg
IFB0.jpg (43.53 KiB) Viewed 10624 times