PICKIT WI-Fire PIC32MZ2048EFG100 SD-Card

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

PICKIT WI-Fire PIC32MZ2048EFG100 SD-Card

Post by stefan.erni »

Hi Ben
on my board PICKIT WI-Fire PIC32MZ2048EFG100 200MHz is an sd-card.
I can write to the card nice if I use the software pin like in the png.
But to use the hardware spi pins (SPI3) it's not possible to choose.
It's not in the MOSI/MISO remap. How can I add them?
Sd-card-fat1.PNG
Pin sd-card
(31.47 KiB) Downloaded 10149 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: PICKIT WI-Fire PIC32MZ2048EFG100 SD-Card

Post by Benj »

Hello,

Right the remappable functionality is organised into banks on the selected device. We have added all the banks to the definition file but only the first bank is currently functional.

So for now I have swapped the bank order which should allow you to select the correct pin to drive the SD card.

Simply copy the attached file into your "Flowcode 7/FCD/PIC32" folder and restart Flowcode.
ChipKIT Wi-FIRE Bootloader.fcdx
(47.59 KiB) Downloaded 335 times
Let us know how you get on.

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: PICKIT WI-Fire PIC32MZ2048EFG100 SD-Card

Post by Benj »

I think I've now fixed it so that the SPI CAL will work to bring in both MOSI banks if more than one bank is available.

Simply copy the attached file into your "Flowcode 7/components" folder. The above fix should not be needed now but will not harm anything.
cal_spi.fcpx
(11.79 KiB) Downloaded 358 times

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: PICKIT WI-Fire PIC32MZ2048EFG100 SD-Card

Post by stefan.erni »

it's working now with the pin. So I wrote a macro to insert easy in all my programs to write a testfile.
There is a problem on the end of the macro, with "write to the next sector". If I open the file, only the first sector is correct.
Can You help me with this?
file_write_test1.FCM
(5.92 KiB) Downloaded 354 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: PICKIT WI-Fire PIC32MZ2048EFG100 SD-Card

Post by Benj »

Hello Stefan,

The problem could be that you are setting .idx_local to 0 outside of the loop 10 times loop. If you move the calculation to the start of the loop before the loop 512 times loop then hopefully that will work correctly.

Let me know how you get on.

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: PICKIT WI-Fire PIC32MZ2048EFG100 SD-Card

Post by stefan.erni »

Hi Ben
Yes perfect. 10 block's are nice on the disk.

There is a question more...
How Can I enable and read the timer1 before start writing and after writing, and write both to uart?

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: PICKIT WI-Fire PIC32MZ2048EFG100 SD-Card

Post by Benj »

How Can I enable and read the timer1 before start writing and after writing, and write both to uart?
The easy way is to use a count variable maybe of type UINT, set this to 0 before enabling the interrupt.

Enable the interrupt with a fairly fast interrupt frequency just before you start writing to the file.

Inside the interrupt macro increment the count variable. count = count + 1

At the end of the file write loop disable the timer interrupt.

The count variable now contains the number of interrupts, which you can then convert to a time by multiplying by (1 / interrupt frequency).

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: PICKIT WI-Fire PIC32MZ2048EFG100 SD-Card

Post by stefan.erni »

Hi Ben

Good idea. But the Irq on this chip is not working........
I tried also with the bootladerversion, but its the same. On another chip I used IRQ.
Do I something wrong here?
Attachments
Flowcode1-chipkit-wi-fire-1.fcfx
IRQ is not working...
(22.45 KiB) Downloaded 341 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: PICKIT WI-Fire PIC32MZ2048EFG100 SD-Card

Post by Benj »

Hello,

I'm investigating this for you now. It seems the timer interrupt is firing after the correct amount of time but then locking up.

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: PICKIT WI-Fire PIC32MZ2048EFG100 SD-Card

Post by Benj »

Right I've got further on this but so far not managed to fix the issue.

The timer interrupt is working fine and running as expected. However as soon as you add any code to the interrupt macro the interrupt causes the program to hang.

I have proven this by taking code out of the timer interrupt macro and adding it to the interrupt definition C code and there it is working.

I'm currently in discussions with Microchip to try and get this resolved.

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: PICKIT WI-Fire PIC32MZ2048EFG100 SD-Card

Post by Benj »

Right this FCD seems to solve the problem. You will get a warning when compiling that the optimisation level is not supported and being removed however it does fix the freezing interrupt problem for me.

Strangely just switching off optimisation does not fix the problem.
ChipKIT Wi-FIRE Bootloader.fcdx
(47.59 KiB) Downloaded 330 times
I'm still investigating so hopefully we can find a better solution that allows optimisation to function.

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: PICKIT WI-Fire PIC32MZ2048EFG100 SD-Card

Post by stefan.erni »

Hi Ben

Thank You for the Bootloader.fcdx. Is it possible to have it for the PIC32MZ2048EFG100 chip also.

I like the Bootloader version, but I use the USB Pin's for sending controldate to the PC. So I did not jet change to the Bootloaderversion. What about the another USB port from the board. Is it soon possible to use?

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: PICKIT WI-Fire PIC32MZ2048EFG100 SD-Card

Post by Benj »

Hi,

You can make the change for any PIC32MZ chip by doing the following.

Click Build -> Compiler Options

Ensure the PIC32 Default is selected

Ensure the Compiler Tab is selected

Find the part of the Parameters that says -O1

Change this to -Os

Click the save button top right of the window.

Give the new setting a name, e.g. PIC32MZINT

Click OK

Highlight the new option on the left menu and check the Default tickbox is ticked.

Click OK.

Hopefully now the interrupts won't crash the chip any more.

To go back simply go back into the compiler options, select default on the left and tick the default tickbox.

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: PICKIT WI-Fire PIC32MZ2048EFG100 SD-Card

Post by stefan.erni »

Hi Ben

First I would like to mention that the chipkit WI-Fireboard is very nicely integrated into Flowcode. Thank you very much.

But I have a little problem with the IRQ ant the chipkit Wi-Fire
I tried to change from 01 to 0s but in the bootlaoder is alway this 01. I can not even click in the box with the mouse....
wi-fire-no_bootloader.PNG
(20.92 KiB) Downloaded 8698 times

wi-fire-with_bootloader.PNG
(20.56 KiB) Downloaded 8698 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: PICKIT WI-Fire PIC32MZ2048EFG100 SD-Card

Post by Benj »

Hello,

Some of the Flowcode FCD (Flowcode Chip Definition) files override the compiler options.

To edit these you need to edit the FCD file in a text editor. Please note that Windows will not let you edit the file in it's default location. You need to copy to somewhere you can edit the file and then copy back.
CompOpt.jpg
CompOpt.jpg (142.57 KiB) Viewed 13552 times

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: PICKIT WI-Fire PIC32MZ2048EFG100 SD-Card

Post by stefan.erni »

Hi Ben

I changed and in the Box now I it's 0s.
something changed with the IRQ.
But I can put only one command in the IRQ-macro. If it's more than one the programm is not running anymore

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: PICKIT WI-Fire PIC32MZ2048EFG100 SD-Card

Post by stefan.erni »

Hi Ben

I wrote a small program for the IRQ
It's working if I disable the part.
What can be the problem? In the attachment is the small program.
IRQ1_1.PNG
(21.24 KiB) Downloaded 8657 times
Attachments
Flowcode7_bootloader_IRQ_test.fcfx
(12.77 KiB) Downloaded 205 times

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: PICKIT WI-Fire PIC32MZ2048EFG100 SD-Card

Post by stefan.erni »

I need a litle help to solve this IRQ Problem....

Post Reply