EEPROM/FLASH dspMIAC

For MIAC users to discuss projects, applications, and any other issues related to the MIAC unit.

Moderators: Benj, Mods

gavo4
Posts: 92
Joined: Sat Aug 25, 2018 7:58 pm
Been thanked: 8 times
Contact:

EEPROM/FLASH dspMIAC

Post 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

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: EEPROM/FLASH dspMIAC

Post by Benj »

Hi Gavin,

Please refer to this forum thread.

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

gavo4
Posts: 92
Joined: Sat Aug 25, 2018 7:58 pm
Been thanked: 8 times
Contact:

Re: EEPROM/FLASH dspMIAC

Post 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
Attachments
TAG+Reader+E2.fcfx
(27.26 KiB) Downloaded 241 times

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: EEPROM/FLASH dspMIAC

Post 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.

gavo4
Posts: 92
Joined: Sat Aug 25, 2018 7:58 pm
Been thanked: 8 times
Contact:

Re: EEPROM/FLASH dspMIAC

Post 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

gavo4
Posts: 92
Joined: Sat Aug 25, 2018 7:58 pm
Been thanked: 8 times
Contact:

Re: EEPROM/FLASH dspMIAC

Post by gavo4 »

My Latest Try attached....;-)
Attachments
TAG+Reader+E3.fcfx
(29.08 KiB) Downloaded 239 times

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: EEPROM/FLASH dspMIAC

Post by LeighM »

I've made a few changes to DataIn and DataOut
not had chance to test it though
Attachments
TAG+Reader+E3 LM.fcfx
(28.87 KiB) Downloaded 248 times

gavo4
Posts: 92
Joined: Sat Aug 25, 2018 7:58 pm
Been thanked: 8 times
Contact:

Re: EEPROM/FLASH dspMIAC

Post by gavo4 »

Thanks Leigh!,

Will give it a go...;-)

gavo4
Posts: 92
Joined: Sat Aug 25, 2018 7:58 pm
Been thanked: 8 times
Contact:

Re: EEPROM/FLASH dspMIAC

Post 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

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: EEPROM/FLASH dspMIAC

Post 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
Attachments
EEPROM_DEMO.fcfx
(16.86 KiB) Downloaded 222 times

gavo4
Posts: 92
Joined: Sat Aug 25, 2018 7:58 pm
Been thanked: 8 times
Contact:

Re: EEPROM/FLASH dspMIAC

Post 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

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: EEPROM/FLASH dspMIAC

Post 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 10343 times

gavo4
Posts: 92
Joined: Sat Aug 25, 2018 7:58 pm
Been thanked: 8 times
Contact:

Re: EEPROM/FLASH dspMIAC

Post by gavo4 »

Hi Leigh,

8.0.0.6

Regards,

Gavin

gavo4
Posts: 92
Joined: Sat Aug 25, 2018 7:58 pm
Been thanked: 8 times
Contact:

Re: EEPROM/FLASH dspMIAC

Post by gavo4 »

This is what I have..
Attachments
Clipboard01.jpg
Clipboard01.jpg (113.75 KiB) Viewed 10343 times

gavo4
Posts: 92
Joined: Sat Aug 25, 2018 7:58 pm
Been thanked: 8 times
Contact:

Re: EEPROM/FLASH dspMIAC

Post 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

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: EEPROM/FLASH dspMIAC

Post 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

gavo4
Posts: 92
Joined: Sat Aug 25, 2018 7:58 pm
Been thanked: 8 times
Contact:

Re: EEPROM/FLASH dspMIAC

Post by gavo4 »

Hi Leigh,

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

Regards,

Gavin
Attachments
Clipboard03.jpg
Clipboard03.jpg (40.29 KiB) Viewed 10339 times

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: EEPROM/FLASH dspMIAC

Post 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

gavo4
Posts: 92
Joined: Sat Aug 25, 2018 7:58 pm
Been thanked: 8 times
Contact:

Re: EEPROM/FLASH dspMIAC

Post 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
Attachments
TAG+Reader+E3 LM.fcfx
(28.54 KiB) Downloaded 159 times

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: EEPROM/FLASH dspMIAC

Post 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.

gavo4
Posts: 92
Joined: Sat Aug 25, 2018 7:58 pm
Been thanked: 8 times
Contact:

Re: EEPROM/FLASH dspMIAC

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

gavo4
Posts: 92
Joined: Sat Aug 25, 2018 7:58 pm
Been thanked: 8 times
Contact:

Re: EEPROM/FLASH dspMIAC

Post by gavo4 »

Card 2 data
Attachments
Card 2 Save read back.jpg
Card 2 Save read back.jpg (106.62 KiB) Viewed 10302 times
Card 2 Read Back.jpg
Card 2 Read Back.jpg (112.16 KiB) Viewed 10302 times
Card 2 Read Back Hold OK.jpg
Card 2 Read Back Hold OK.jpg (110.27 KiB) Viewed 10302 times

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: EEPROM/FLASH dspMIAC

Post 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

gavo4
Posts: 92
Joined: Sat Aug 25, 2018 7:58 pm
Been thanked: 8 times
Contact:

Re: EEPROM/FLASH dspMIAC

Post 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

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: EEPROM/FLASH dspMIAC

Post by LeighM »

IFB0.jpg
IFB0.jpg (43.53 KiB) Viewed 10293 times

Post Reply