View previous topic :: View next topic |
Author |
Message |
gabirelms
Joined: 28 Jun 2014 Posts: 38
|
USB wake-up with PIC16LF1459 |
Posted: Sun Jun 29, 2014 5:12 am |
|
|
Hi all,
PIC16LF1459, data sheet, page 1:
Interrupt-on-Change (IOC) on D+/D- for USB Host Detection.
But in my testing the voltage is not enough for reading and wake up.
d+ line volt 3.3v to 2.57. But for wake-up I think I need 0v to 3.3v like, or at least 1v-3.3v.
My plan is first 20 seconds when I power ON the device is working at 48MHz, and I can connect the device to the computer... but it would be better if I can connect to USB any moment.
Any help would be appreciated
Thanks |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19543
|
|
Posted: Sun Jun 29, 2014 1:22 pm |
|
|
No.
IOC, only requires the signal to change from Vil to Vih, or from Vih to Vil.
The USB signals don't sit at a DC voltage, they are continuously active. Even on an 'idle' USB bus, the host will be scanning every few mSec with clocks generated on the lines. These are fast (12MHz) on a standard USB bus. So what your voltmeter shows doesn't reflect what is on the bus. The signals are large enough to trigger IOC.
The pins have to be set as input. Then read. When you attach to the bus, the activity will trigger IOC. Then the USB peripheral has to be enabled ASAP, so the host sees the pull-ups on the lines, and detects the device is present, triggering enumeration. |
|
|
gabirelms
Joined: 28 Jun 2014 Posts: 38
|
|
Posted: Sun Jun 29, 2014 2:14 pm |
|
|
Thanks very much, I will try tomorrow. |
|
|
gabirelms
Joined: 28 Jun 2014 Posts: 38
|
|
Posted: Mon Jun 30, 2014 5:13 am |
|
|
I'm trying it, but it doesnt work yet.
How can I generate interrupt for RA0 and RA1 ? Can you help me with the code ? |
|
|
gabirelms
Joined: 28 Jun 2014 Posts: 38
|
|
Posted: Mon Jun 30, 2014 5:31 am |
|
|
My code:
Code: |
MCU used : PIC16LF1459
Clock : 2MHz while sleep
Compile used : CCS 5.015
// Fuse settings fCCS compiler
#FUSES NOWDT //No Watch Dog Timer
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#fuses MCLR
#fuses PUT
#fuses NOWDT
// Change on interrupt
#int_rb
void RB_ISR(void)
{
if((IOCAFA0==1)||(IOCAFA1==1))
{
flag_usb_wake=1;
IOCAFA0=0;
IOCAFA1=0;
}
}
// main code interrupt on PIN RA0 and RA1
USBEN=0;
IOCAN=0;
IOCAP=0;
IOCAN0=1;
IOCAN1=1;
//IOCAP0=1;
//IOCAP1=1;
INTCONRABIE=1;
INTCONRABIF=0;
kll=PORTA;
kll=PORTB;
IOCAF=0x00;
IOCAFA0=0;
IOCAFA1=0;
While(1)
{
if(flag_usb_wake==1)
{
flag_usb_wake=0;
output_bit(LED1,1);
delay_ms(1000);
output_bit(LED1,0);
delay_ms(1000);
IOCAN0=1;
IOCAN1=1;
IOCAFA0=0;
IOCAFA1=0;
INTCONRABIE=1;
INTCONRABIF=0;
}
}
|
|
|
|
gabirelms
Joined: 28 Jun 2014 Posts: 38
|
|
Posted: Tue Jul 01, 2014 8:25 am |
|
|
The only solution I found is to take 3.3v from usb line (with voltage regulator), and connect it to any B port to make the interrupt.
But I don't understand this from data sheet:
Interrupt-on-Change (IOC) on D+/D- for USB Host Detection. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19543
|
|
Posted: Tue Jul 01, 2014 9:07 am |
|
|
Seriously, look at using the CCS functions.
What you have is basically 'assembler' written in C. Key is that the functions to do things are already written for you in CCS (except very occasionally), and nobody is going to spend the time wandering through the data sheet trying to work out what is wrong.... |
|
|
|