Page 1 of 1

PICKIT WI-Fire PIC32MZ2048EFG100 SD-Card

Posted: Thu Jan 12, 2017 6:31 pm
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

Re: PICKIT WI-Fire PIC32MZ2048EFG100 SD-Card

Posted: Fri Jan 13, 2017 11:24 am
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 344 times
Let us know how you get on.

Re: PICKIT WI-Fire PIC32MZ2048EFG100 SD-Card

Posted: Fri Jan 13, 2017 11:50 am
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 368 times

Re: PICKIT WI-Fire PIC32MZ2048EFG100 SD-Card

Posted: Fri Jan 13, 2017 2:41 pm
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 363 times

Re: PICKIT WI-Fire PIC32MZ2048EFG100 SD-Card

Posted: Fri Jan 13, 2017 4:05 pm
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.

Re: PICKIT WI-Fire PIC32MZ2048EFG100 SD-Card

Posted: Fri Jan 13, 2017 4:43 pm
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?

Re: PICKIT WI-Fire PIC32MZ2048EFG100 SD-Card

Posted: Fri Jan 13, 2017 4:59 pm
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).

Re: PICKIT WI-Fire PIC32MZ2048EFG100 SD-Card

Posted: Fri Jan 13, 2017 5:52 pm
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?

Re: PICKIT WI-Fire PIC32MZ2048EFG100 SD-Card

Posted: Fri Jan 13, 2017 6:54 pm
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.

Re: PICKIT WI-Fire PIC32MZ2048EFG100 SD-Card

Posted: Mon Jan 16, 2017 4:28 pm
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.

Re: PICKIT WI-Fire PIC32MZ2048EFG100 SD-Card

Posted: Tue Jan 17, 2017 11:31 am
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 338 times
I'm still investigating so hopefully we can find a better solution that allows optimisation to function.

Re: PICKIT WI-Fire PIC32MZ2048EFG100 SD-Card

Posted: Tue Jan 17, 2017 12:37 pm
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?

Re: PICKIT WI-Fire PIC32MZ2048EFG100 SD-Card

Posted: Tue Jan 17, 2017 5:11 pm
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.

Re: PICKIT WI-Fire PIC32MZ2048EFG100 SD-Card

Posted: Fri Mar 24, 2017 10:43 am
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

Re: PICKIT WI-Fire PIC32MZ2048EFG100 SD-Card

Posted: Fri Mar 24, 2017 10:48 am
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 13830 times

Re: PICKIT WI-Fire PIC32MZ2048EFG100 SD-Card

Posted: Fri Mar 24, 2017 11:14 am
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

Re: PICKIT WI-Fire PIC32MZ2048EFG100 SD-Card

Posted: Mon Mar 27, 2017 11:11 am
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

Re: PICKIT WI-Fire PIC32MZ2048EFG100 SD-Card

Posted: Wed Mar 29, 2017 10:34 am
by stefan.erni
I need a litle help to solve this IRQ Problem....