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 CCS Technical Support

USB wake-up with PIC16LF1459

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
gabirelms



Joined: 28 Jun 2014
Posts: 38

View user's profile Send private message

USB wake-up with PIC16LF1459
PostPosted: Sun Jun 29, 2014 5:12 am     Reply with quote

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: 19481

View user's profile Send private message

PostPosted: Sun Jun 29, 2014 1:22 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Jun 29, 2014 2:14 pm     Reply with quote

Thanks very much, I will try tomorrow.
gabirelms



Joined: 28 Jun 2014
Posts: 38

View user's profile Send private message

PostPosted: Mon Jun 30, 2014 5:13 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Jun 30, 2014 5:31 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Jul 01, 2014 8:25 am     Reply with quote

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: 19481

View user's profile Send private message

PostPosted: Tue Jul 01, 2014 9:07 am     Reply with quote

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....
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
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