Page 1 of 1

ECIO40P16 and dsPIC33EP256MU806 chip

Posted: Thu Apr 15, 2021 8:14 am
by kennethnilsen69
I have make my own pcb with the same chip as in ECIO40P16 and there are a few things I do not understand

ECIO40P16 has an external crystal at 8MHz but runs at 140MHz. how is this possible?
Mine only works properly if I choose 8MHz but as you know, it is much slower than 140MHz. so what is it I have not understood here?

I also can't use USB to upload the Hex file. I have to use PICkit4. any tips on how I can do this? I have uploaded the same bootloader that must be used on ECIO40P16 for the USB upload to work.

If I erase the ECIO chip, it stops working with USB. and when I upload the bootloader the USB works again. so I know the bootloader is working properly.
But on my pcb it will not work. is unsure if this has anything to do with the crystal. any ideas?

Re: ECIO40P16 and dsPIC33EP256MU806 chip

Posted: Thu Apr 15, 2021 10:00 am
by Benj
Hello,

We use the onboard PLL to multiply up the 8MHz input clock frequency up to 140MHz. Unfortunatley you currently have to do this using C code.

Code: Select all

//Setup configuration for 70MIPs using 8MHz Crystal
PLLFBD = 68; // M=70
CLKDIVbits.PLLPOST = 0; // N1=2
CLKDIVbits.PLLPRE = 0; // N2=2
OSCTUN = 0; //Tune FRC oscillator, if FRC is used

//Disable Watch Dog Timer
RCONbits.SWDTEN = 0;

// Clock switching to incorporate PLL
__builtin_write_OSCCONH(0x03); // Initiate Clock Switch to Primary Oscillator with PLL (NOSC=0b011
__builtin_write_OSCCONL(0x01); // Start clock switching
while(OSCCONbits.COSC != 0b011);

// Wait for Clock switch to occur
while(OSCCONbits.LOCK != 1);

//USB H/W initialization for 70 MIPs
ACLKCON3 = 0x24C1;
ACLKDIV3 = 0x7;

// Wait for PLL to lock
ACLKCON3bits.ENAPLL = 1;
while(ACLKCON3bits.APLLCK != 1);
We put the bootloader into the auxillary flash and this way the entirety of program flash can be used by the users program and when erasing we can erase the entire program flash in a single command.

Re: ECIO40P16 and dsPIC33EP256MU806 chip

Posted: Thu Apr 15, 2021 12:32 pm
by kennethnilsen69
Hi Ben :-) can I do this in flowcode with the C Code icon and then upload it to the chip with the PICkit4 device?

Is this just a one-time thing to do? it will stay that way after I upload the regular hex program

Re: ECIO40P16 and dsPIC33EP256MU806 chip

Posted: Thu Apr 15, 2021 12:40 pm
by kennethnilsen69
like this?

Re: ECIO40P16 and dsPIC33EP256MU806 chip

Posted: Thu Apr 15, 2021 12:59 pm
by kennethnilsen69
bootloader into the auxillary flash did the trick. now usb and 140MHz work and i can program it like a regular ECIO40P16 :-) Thank you so much Ben :-)

Re: ECIO40P16 and dsPIC33EP256MU806 chip

Posted: Thu Apr 15, 2021 4:14 pm
by kennethnilsen69
Hmm it seems to always enter bootloader even without USB connected. and stays there for about 1 minute and 50 seconds then it goes out of Bootloader and boots up normally. are these any settings I am missing in MPLAB IPE? or there may be a fault in the pcb card.

Re: ECIO40P16 and dsPIC33EP256MU806 chip

Posted: Mon Apr 19, 2021 12:26 pm
by Benj
Aha well done glad you got it working.

In our bootloader firmware we check to see if a voltage on an input pin used as a USB detect pin is present when starting. The pin is pulled low by a resistor and connected to the VUSB pin from the USB socket.

If the voltage is not present then we jump directly to the user's program.

If the voltage is present then we wait for input from the PC for a few seconds. It should be possible to configure how long it waits for input by adjusting a timeout value.

Re: ECIO40P16 and dsPIC33EP256MU806 chip

Posted: Tue Apr 20, 2021 8:19 am
by kennethnilsen69
I added a 10k resistor between VUSB and GND but unfortunately it did not help. it still goes straight into the bootloader and stays there for 1 minute and 50 seconds before booting into using the program.

any more ideas on why?

I use the same bootloader as you have on ECIO :-)

Re: ECIO40P16 and dsPIC33EP256MU806 chip

Posted: Tue Apr 20, 2021 1:40 pm
by kersing
Your solution is not what Ben describes. An I/O pin is connected VUSB and has a pull down. Not VUSB is connected to GND with a resistor.
The question is of course which I/O pin...

Re: ECIO40P16 and dsPIC33EP256MU806 chip

Posted: Tue Apr 20, 2021 2:21 pm
by kennethnilsen69
kersing wrote:
Tue Apr 20, 2021 1:40 pm
Your solution is not what Ben describes. An I/O pin is connected VUSB and has a pull down. Not VUSB is connected to GND with a resistor.
The question is of course which I/O pin...
thank you very much for that kersing :-) it worked when I found the right input port :-))))
Now it boots up properly :-)))