EB037 MMC card reader

For E-blocks user to discuss using E-blocks and programming for them.

Moderators: Benj, Mods

Post Reply
Pierre67
Posts: 15
Joined: Mon Mar 11, 2013 10:42 am
Has thanked: 4 times
Contact:

EB037 MMC card reader

Post by Pierre67 »

Hello,

I'm using a PIC 16F877A and I would like to manage to write some data on an MMC card and I would like that data to be readable easily from a computer. So I thought I'd just have to use the FAT component built-in flowcode because it seems a really easy way to do the job.
But unfortunately, if I try to use the FAT functions built-in flowcode I've got an error during compilation saying there's not enough memory or something. I'm wondering if the chip (16F877A) is compatible with the FAT functions ? Otherwise, is there a way to fix this or to mange to get the job done another way ?

Thanks in advance for your help :D !

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: EB037 MMC card reader

Post by kersing »

The 16f877a is not compatible with the FAT component.

There are several solutions if you want to exchange data with a computer:
1) Use the EB037 with a PIC with more memory.
2) Use something like Open Hardware Data Logger
3) Use something like the Elektor USB datalogger, interfaces with a serial port.

I would personally go for option 1 as it is by far the cheapest solution.
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

Pierre67
Posts: 15
Joined: Mon Mar 11, 2013 10:42 am
Has thanked: 4 times
Contact:

Re: EB037 MMC card reader

Post by Pierre67 »

Thanks a lot for your quick answer !
That's what I fought, The PIC is the problem.

Can you advise me a PIC that is compatible with the FAT component and EB006 board ?

User avatar
JohnCrow
Valued Contributor
Valued Contributor
Posts: 1367
Joined: Wed Sep 19, 2007 1:21 pm
Location: Lincolnshire
Has thanked: 364 times
Been thanked: 716 times
Contact:

Re: EB037 MMC card reader

Post by JohnCrow »

Hi Pierre

Ive used the 18F4550 or 18f4455 devices for projects with the card reader. Should have plenty of memory in those.
1 in 10 people understand binary, the other one doesn't !

Pierre67
Posts: 15
Joined: Mon Mar 11, 2013 10:42 am
Has thanked: 4 times
Contact:

Re: EB037 MMC card reader

Post by Pierre67 »

I chose to try the PIC 18F4550 and to use the FAT component but I can't make it work...

I wanted to test the card with a simple program that create a file (test.txt) and writes a "hello world" into that file (see attachment) but every time I get this error :

Flowcode1.c(1171:6): error: unknown identifier 'Read_Byte_From_Buffer'
Flowcode1.c(1171:6): error: failed to generate expression
Flowcode1.c(1171:6): error: invalid operand 'Read_Byte_From_Buffer((Idx) + 2) '
Flowcode1.c(1171:39): error: failed to generate expression
Flowcode1.c(1593:11): error: unknown identifier 'MX_SPI_BYTE'
Flowcode1.c(1593:11): error: failed to generate expression
Flowcode1.c(1593:11): error: invalid operand 'MX_SPI_BYTE(0xFF)'
Flowcode1.c(1593:9): error: failed to generate expression
Flowcode1.c(1594:6): warning: local variable 'RetVal' may be used uninitialized
Flowcode1.c success

failure
Code retour = 1
Flowcode a été incapable de traduire l'algorigramme en code C à cause des erreurs suivantes :


Si votre algorigramme contient du code C, examinez ce code soigneusement. Si votre algorigramme ne contient aucun code C ou si vous avez minutieusement révisé le code, contactez le Support Technique.


TERMINÉ







Can you help me make that work ? I really need to record data into that card for a school project and my exam date is soon...
Attachments
testmmc.PNG
(75.71 KiB) Downloaded 5228 times

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: EB037 MMC card reader

Post by kersing »

Which version of Flowcode are you using? Could you post you flowcode file?
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

Pierre67
Posts: 15
Joined: Mon Mar 11, 2013 10:42 am
Has thanked: 4 times
Contact:

Re: EB037 MMC card reader

Post by Pierre67 »

I'm using flowcode 5.0 and here is my flowcode file (see attachment)
Attachments
EB037 test.fcf
(7 KiB) Downloaded 404 times

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: EB037 MMC card reader

Post by Benj »

Hello Pierre,

Try upgrading to v5.5 and your program should then compile correctly. You can upgrade by clicking Help -> Check for updates.

Pierre67
Posts: 15
Joined: Mon Mar 11, 2013 10:42 am
Has thanked: 4 times
Contact:

Re: EB037 MMC card reader

Post by Pierre67 »

Hello,

I upgraded to flowcode 5.5 but I still can't make my test program work. Now it compiles correctly but when I check on the computer if the file has been written, there is nothing on the card.
I think the problem is that EB037 is connected to the wrong pin or something, because the PIC seems not being able to communicate with the EB037.

Could someone send me a working .fcf file which writes a simple file on an MMC card through EB037 with the PIC 18F4550 ?

Pierre67
Posts: 15
Joined: Mon Mar 11, 2013 10:42 am
Has thanked: 4 times
Contact:

Re: EB037 MMC card reader

Post by Pierre67 »

I'm passing my exam very soon and if I don't get to write that file on the card, I'm in trouble... :roll:
Could someone help please ?

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: EB037 MMC card reader

Post by Benj »

Ok what does your hardware look like?
Which port are you connecting the E-block to?
Which patch setting are you using?
What crystal frequency?
Is the program you posted the one your still using?
If so what about loading one of the examples from the main examples download and looking at the debug messages that are displayed on the LCD?

Pierre67
Posts: 15
Joined: Mon Mar 11, 2013 10:42 am
Has thanked: 4 times
Contact:

Re: EB037 MMC card reader

Post by Pierre67 »

The Hardware I'm using :

- PIC 18F4450
- programming board EB006
- card reader EB037
- MMC card of 1Go, in FAT 16 format

the EB037 is connected to the B port but I tried different ports and it doesn't change anything. I also tried to uncheck "software mode" in the advanced properties of the FAT component, I don't know what this does by the way :roll: , but it doesn't seem to change anything exept the fact that there is only the CS (Chip Select) thing left in the connections after I did that.
I'm not sure what you mean by "patch setting" but the jumper is at A on the EB037. Concerning the crystal frequency I tried differents frequencies for the PIC but it doesn't change anything neither.

I also tested the exmple programs, especially the "Create File" program. The LCD kept printing "Waiting for Card" so I suppose the PIC can't even communicate with the card.

The program I posted is still the one I use. So can you check if there is anything wrong with the file, or better, could you directly supply me a file where everything is configured properly ?

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: EB037 MMC card reader

Post by kersing »

Pierre67 wrote:The Hardware I'm using :

- PIC 18F4450
- programming board EB006
- card reader EB037
- MMC card of 1Go, in FAT 16 format

the EB037 is connected to the B port but I tried different ports and it doesn't change anything. I also tried to uncheck "software mode" in the advanced properties of the FAT component, I don't know what this does by the way :roll: , but it doesn't seem to change anything exept the fact that there is only the CS (Chip Select) thing left in the connections after I did that.
I'm not sure what you mean by "patch setting" but the jumper is at A on the EB037.
Have you checked the manual for this board? In chapter 5 there is a table with the controllers and the required jumper settings. The 18f4550 is not listed in the column for setting A, so that is probably not the correct setting... The correct setting is probably jumper C with the use of the patch system. See the circuit diagram on page 9 for more information on the patch system. (You need to connect pins of P2 with a wire to pins of P1 according to the settings for SDI/SDO/SCK and CS in the component properties)
To verify which bit of the controller port is available on which pin of the DB9 connector you should probably consult the manual for the EB006 as well.

Good luck!
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

Pierre67
Posts: 15
Joined: Mon Mar 11, 2013 10:42 am
Has thanked: 4 times
Contact:

Re: EB037 MMC card reader

Post by Pierre67 »

I switched the jumper to "patch system" and connected everything correctly. Now, the PIC seems to be able to communicate with the card but I still cannot write anything on the card.

I connected an LCD screen to monitor the return value of FAT component function (see .fcf attached). It keeps printing "255" (0xFF). According to the MMC programming strategy document (see attachment) on page 3, this return code means "MMC Not Reset Correctly". What does this mean ? How can I "correctly reset the MMC card" ?
Attachments
MMC Programming Strategy.pdf
(76.21 KiB) Downloaded 396 times
EB037 test with LCD monitoring.fcf
(9.5 KiB) Downloaded 316 times

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: EB037 MMC card reader

Post by Benj »

Hello,

In your project settings please ensure the clock speed is setup correctly to match your hardware.

Also in the project settings go into the config settings and disable these options.

Watchdog Timer
Low Voltage Program
Extended CPU

Hopefully then the program will run as expected.

User avatar
JohnCrow
Valued Contributor
Valued Contributor
Posts: 1367
Joined: Wed Sep 19, 2007 1:21 pm
Location: Lincolnshire
Has thanked: 364 times
Been thanked: 716 times
Contact:

Re: EB037 MMC card reader

Post by JohnCrow »

Hi Pierre

Try this one.
Ive changed the chip config settings to ones that I normally use to set up a project with this device.
Its working with a selection of cards on my system.
EB037 test_modified.fcf
(7 KiB) Downloaded 370 times
1 in 10 people understand binary, the other one doesn't !

Pierre67
Posts: 15
Joined: Mon Mar 11, 2013 10:42 am
Has thanked: 4 times
Contact:

Re: EB037 MMC card reader

Post by Pierre67 »

Thanks a lot, I will try this monday !

Pierre67
Posts: 15
Joined: Mon Mar 11, 2013 10:42 am
Has thanked: 4 times
Contact:

Re: EB037 MMC card reader

Post by Pierre67 »

I tried the file JohnCrow gave me and I didn't touch anything, but I still can't write anything on the card... I tried 2 different cards, it's all the same. I checked and re-checked that the cards are well formatted and indeed they are.
Then I plugged an lcd screen to monitor the return value of init_FAT() function and the strange thing is that with one card the ruturn value is 0xFE (MMC Not Ready For Operation) and with the other card I get 0xFF (MMC Not Reset Correctly).

What does that mean ?

User avatar
JohnCrow
Valued Contributor
Valued Contributor
Posts: 1367
Joined: Wed Sep 19, 2007 1:21 pm
Location: Lincolnshire
Has thanked: 364 times
Been thanked: 716 times
Contact:

Re: EB037 MMC card reader

Post by JohnCrow »

Hi Pierre
I know the program I sent was working properly.
The jumper on my card reader is set to A
Card to Port B
The cards I tried were
2GB formatted to FAT.
32kB allocation size

I did have problems with some types of card with earlier versions of FC, but not had any with the latter releases.
The problems I had were mostly due to the speed of the card. Above class 4 gave problems, but this was sorted in the FC component.

If yours are fast cards might be worth trying a class2.

What make are your cards?
1 in 10 people understand binary, the other one doesn't !

Pierre67
Posts: 15
Joined: Mon Mar 11, 2013 10:42 am
Has thanked: 4 times
Contact:

Re: EB037 MMC card reader

Post by Pierre67 »

Sorry for late repply but matrix website apparently had some issues and the my post has been deleted...

So, I tried two different cards with the exact same settings as you but It still won't write anything...

my cards are :

- Canon MMC-8M (that's an old card)
- Transcend MMC plus of 1GB

The first one's class is certainly below 4 so it should have worked.
I think I really tried evertyhing and I guess there is nothing left to try... Anyway it's too late and I won't be able to try anything else.

Thank you guys anyway, even thought I didn't manage to achieve my goal in time, your help has been greatly appreciated =)

User avatar
JohnCrow
Valued Contributor
Valued Contributor
Posts: 1367
Joined: Wed Sep 19, 2007 1:21 pm
Location: Lincolnshire
Has thanked: 364 times
Been thanked: 716 times
Contact:

Re: EB037 MMC card reader

Post by JohnCrow »

Hi Pierre

Sorry to here you didnt get the project finished in time.

As a thought, are you using MMC or SD (SDHC) cards

MMC are the older type and If I remember have 1 less connection than SD cards, the one near the chamfered corner (opposite the write protect switch)
Though they should both work, going by the e-block data sheet.

Ive never used MMC cards and I think they are now very hard to come by.
I still think the problem is card related ( there are so many different cards out there some do give problems with some devices) rather than a fault on the programmer or e-block.
1 in 10 people understand binary, the other one doesn't !

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: EB037 MMC card reader

Post by Benj »

Hello,

I think as part of all the mods we did to support FAT32, SDHC and all variants of SD cards I may have broken MMC support.

I know we had MMC's working originally with RAW mode where we were just reading and writing data directly and skipping the filesystem.

Not sure I have ever seen a working MMC with the FAT component though I could be wrong, might be worth a quick test with FCv4.

Post Reply