ECIO40P16 and dsPIC33EP256MU806 chip

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
kennethnilsen69
Posts: 98
Joined: Tue Sep 01, 2015 9:37 pm
Been thanked: 14 times
Contact:

ECIO40P16 and dsPIC33EP256MU806 chip

Post 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?
Last edited by kennethnilsen69 on Thu Apr 15, 2021 1:01 pm, edited 2 times in total.

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

Re: ECIO40P16 and dsPIC33EP256MU806 chip

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

kennethnilsen69
Posts: 98
Joined: Tue Sep 01, 2015 9:37 pm
Been thanked: 14 times
Contact:

Re: ECIO40P16 and dsPIC33EP256MU806 chip

Post 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

kennethnilsen69
Posts: 98
Joined: Tue Sep 01, 2015 9:37 pm
Been thanked: 14 times
Contact:

Re: ECIO40P16 and dsPIC33EP256MU806 chip

Post by kennethnilsen69 »

like this?

kennethnilsen69
Posts: 98
Joined: Tue Sep 01, 2015 9:37 pm
Been thanked: 14 times
Contact:

Re: ECIO40P16 and dsPIC33EP256MU806 chip

Post 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 :-)

kennethnilsen69
Posts: 98
Joined: Tue Sep 01, 2015 9:37 pm
Been thanked: 14 times
Contact:

Re: ECIO40P16 and dsPIC33EP256MU806 chip

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

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

Re: ECIO40P16 and dsPIC33EP256MU806 chip

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

kennethnilsen69
Posts: 98
Joined: Tue Sep 01, 2015 9:37 pm
Been thanked: 14 times
Contact:

Re: ECIO40P16 and dsPIC33EP256MU806 chip

Post 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 :-)

kersing
Valued Contributor
Valued Contributor
Posts: 2006
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 552 times
Been thanked: 1079 times
Contact:

Re: ECIO40P16 and dsPIC33EP256MU806 chip

Post 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...
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

kennethnilsen69
Posts: 98
Joined: Tue Sep 01, 2015 9:37 pm
Been thanked: 14 times
Contact:

Re: ECIO40P16 and dsPIC33EP256MU806 chip

Post 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 :-)))

Post Reply