CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug Reports on this forum. Send them to support@ccsinfo.com

Request: USB HID Test code for 18LF14K50 12MHz [Solved]
Goto page Previous  1, 2, 3, 4  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
FFT



Joined: 07 Jul 2010
Posts: 92

View user's profile Send private message

PostPosted: Thu Dec 16, 2021 11:12 am     Reply with quote

@PCM programmer

I have 1uF tantalum cap on VUSB pin.
The VUSB pin is connected to 3.3V VCC.
I have three 10uF tantalum caps and four 100nF ceramic caps on 3.3V VCC in total.

Here is the schematic of PIC with USB part :
https://ibb.co/wrFD4mD

So I have .4uF ceramic cap on 3.3V respectively the VUSB pin. PCB is very small and all of them are placed nearly.

I don't have any electrolytic cap on the PCB.
Ttelmah



Joined: 11 Mar 2010
Posts: 17910

View user's profile Send private message

PostPosted: Thu Dec 16, 2021 12:37 pm     Reply with quote

Slightly puzzled by the circuit. You are showing two crystals in parallel
across the oscillator pins?...
The circuit also lists the Vusb capacitor as only 0.1uF, and it is shown as
non polarised, but a tantalum capacitor is polarised.
FFT



Joined: 07 Jul 2010
Posts: 92

View user's profile Send private message

PostPosted: Thu Dec 16, 2021 2:04 pm     Reply with quote

Ttelmah wrote:
Slightly puzzled by the circuit. You are showing two crystals in parallel
across the oscillator pins?...
The circuit also lists the Vusb capacitor as only 0.1uF, and it is shown as
non polarised, but a tantalum capacitor is polarised.

The other crystal is just for backup footprint. And yes all the uF caps are polarised. Vusb is 3.3V, so they tied together.
I think there is no problem on the schematic according to your recommendations
PCM programmer



Joined: 06 Sep 2003
Posts: 21615

View user's profile Send private message

PostPosted: Thu Dec 16, 2021 3:11 pm     Reply with quote

You have a lot of unused pins. Have you set those to be low-level
outputs, rather than leave them as floating inputs ?
FFT



Joined: 07 Jul 2010
Posts: 92

View user's profile Send private message

PostPosted: Mon Dec 27, 2021 11:05 am     Reply with quote

Hello guys,

I think I had a programmer issue.
It worked properly after replacing my Pickit3 with a new one.
But I have 2 PICs faulty - their USB must be burned but other func are working.
I understood this after getting an F one.

Thanks for your help.
FFT



Joined: 07 Jul 2010
Posts: 92

View user's profile Send private message

PostPosted: Mon Jan 10, 2022 5:02 pm     Reply with quote

Hi,

I didn't want to create a new topic.

I have a working USB HID now. (with 12 Mhz ext crystal)
I need to reduce power consumption of the board.
Options are;
1- Reduce CPU clock (but USB should work)
2- Disable USB when unplugged

I tried to change CPUDIV fuse to #fuses CPUDIV4 to reduce cpu clock, but USB didn't work properly.

My current fuses are as follows;
Code:
#fuses NOIESO
#fuses NOFCMEN
#fuses PCLKEN
#fuses NOPUT
#fuses BROWNOUT
#fuses BORV19
#fuses WDT
#fuses WDT512
#fuses MCLR
#fuses NOHFOFST
#fuses NOLVP
#fuses NOXINST
#fuses STVREN
#fuses NOWRT
#fuses NOEBTR

// configure 12MHz clock for USB operation and 48Mhz CPU operation
#fuses HS
#fuses PLLEN   //enable pll, we can now use CPUDIVx fuses
#fuses CPUDIV1 //CPU clock set to 48MHz
#fuses USBDIV2 //when using low speed USB, need to divide 12MHz by 2.  this fuse has no effect when using full speed.

#use delay(clock=48000000, restart_wdt)


I use usb_init_cs() for initialization.

I tried to disable USB when unplugged with as following;
Code:
usb_set_configured(0);
usb_detach();

Then called usb_init_cs() when plugged back, but there is no any change on consumption.

----

I'm OK with 6 or 3 MHz or less CPU speed.

How to reach a proper low power configuration on this?

Thanks
temtronic



Joined: 01 Jul 2010
Posts: 8468
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Jan 10, 2022 5:09 pm     Reply with quote

I have to ask
1) what is the current power consumption ?
2) what is the desired power consumption ?
3) what else is on the PCB ?
4) is this battery powereed ?

so relaly WHY the need to reduce power ?
FFT



Joined: 07 Jul 2010
Posts: 92

View user's profile Send private message

PostPosted: Tue Jan 11, 2022 3:06 am     Reply with quote

FFT wrote:
1- Reduce CPU clock (but USB should work)
2- Disable USB when unplugged

I'm looking for a solution for those two options only.
The other details should not be important I think. When those two options are done, I'm done.
There are a shift register and a I2C DAC on the PCB
Ttelmah



Joined: 11 Mar 2010
Posts: 17910

View user's profile Send private message

PostPosted: Tue Jan 11, 2022 3:53 am     Reply with quote

Key thing that was mentioned earlier, is you need to connect Vusb to
the USB bus, not to your local PSU. It is Vusb that powers the transceivers.
You need a 3.3v regulator from the USB VBUS pin, that powers Vusb. If
you do this, the transceivers will go off when the USB is not connected,
and this also turns off the peripheral when it detects Vusb dropping
below it's requirement.
To drop the CPU clock and retain USB operation, use a 6MHz master
oscillator, and switch to using low speed USB. This drops both the USB
power consumption and the CPU consumption.
FFT



Joined: 07 Jul 2010
Posts: 92

View user's profile Send private message

PostPosted: Tue Jan 11, 2022 3:59 am     Reply with quote

I understood for the HW side.

Isn't there any SW solution to turn off and on the usb?
Isn't it possible that CPU and USB (48Mhz) run on different clock rates?
Ttelmah



Joined: 11 Mar 2010
Posts: 17910

View user's profile Send private message

PostPosted: Tue Jan 11, 2022 4:53 am     Reply with quote

The USB peripheral can be turned off by being sent a suspend by the
USB host. This puts it into 'idle' mode. However the transceivers themselves
are always powered if Vusb is on. The peripheral draws very little current.
the transceiver if powered draws much more. This is why you are seeing so
little reduction when you turn the peripheral off.
Yes, you can run the USB at different speeds to the CPU, but the lowest
power combination is to clock both the USB and the CPU at 6MHz.
FFT



Joined: 07 Jul 2010
Posts: 92

View user's profile Send private message

PostPosted: Tue Jan 11, 2022 5:31 am     Reply with quote

How can I lower the clock of CPU on my current config?
CPUDIV4 didn't work.
I look for a lowest possible clock rate with 12 Mhz crystal which is my current config.
Now everything works on 48 Mhz, so how can I reduce this keeping USB working as it is.
temtronic



Joined: 01 Jul 2010
Posts: 8468
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Jan 11, 2022 6:17 am     Reply with quote

Can you reduce clock speed , yes
Can you turn off USB peripheral, yes

Will you save power . maybe yes, maybe no

Actual power calculations can be complicated and just because you slow the PIC down, doesn't mean you will save power. First it will take the PIC LONGER to execute code. Dropping the speed from say 48MHz to 6 MHz doesn't reduce power by 8x. When you put a peripheral to 'sleep' or 'standby' or 'disabled', you have to account for the time it needs to 'wake up' and become fully operational before the PIC can access it. It is entirely possible that you'll need MORE power by going 'slow and sleepy'. Microchip's AN606, showed how this will happen. It's actually a must read for everyone wanting to run PICs on batteries. There are dozens of ways to reduce or save power both in HW selection and SW coding techniques.
I have to ask WHY reduce power ? This device is attached to a PC via the USB port,so you should be able to easily run it using PC power.
FFT



Joined: 07 Jul 2010
Posts: 92

View user's profile Send private message

PostPosted: Tue Jan 11, 2022 6:30 am     Reply with quote

This device is not attached to USB all the time.
It takes 11.6 mA current now, my target is about 9 mA
Device never sleeps, not a battery powered. But on a sensitive power supply.
I think a clock reduce can lower the consumption enough.

All I need to know is how can I run the CPU at lower sleep when USB runs on it's normal speed.

Also is it possible to disable USB totally when it's unplugged on my chip using my current hardware, so I cannot tweak with Vbus. I wrote my other details on early messages.

That's all.
temtronic



Joined: 01 Jul 2010
Posts: 8468
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Jan 11, 2022 7:04 am     Reply with quote

As a test, I'd use the internal clock,say at 16MHz, record current used. Then, reprogram to say 8MHz clock, record current used
While I don't use that PIC, it'd be easy to see what effect clock speed has on power consumption.
There is an 'L' version of that PIC, so look at the datasheet to see what power it uses.
You can increase the pullup on *MCLR, to reduce power consumption. Same maybe be true with the 2 USB resistors
Using the internal clock should use less power than the external xtal/caps section

There may be other things that can be done. You mention I2C DAC and shift register. they could be drawing power ?
You're looking for a 20% reduction in current, may not be possible,especially if the PIC is running all the time.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2, 3, 4  Next
Page 3 of 4

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group