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

Wake-Up on PIC12LF1501

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



Joined: 22 Aug 2005
Posts: 275

View user's profile Send private message

Wake-Up on PIC12LF1501
PostPosted: Sun Sep 23, 2012 7:53 am     Reply with quote

Hi to all,

I'm in trouble with PIC12LF1501 and wake up from sleep.
I connected on PORTA lines some pushbutton to gnd and PIC must wakeup on pushing.

I enabled pull-ups but , checked with oscilloscope, RA4 and RA3 are not in high state as RA0, RA1 and RA2. So by pushbuttons wakeup doesn't work with RA4 and RA3.

This is main program.
Code:

#include  <12F1501.H>
#include "def12F1501.c"


#FUSES INTRC_IO,NOMCLR,NOWDT,PROTECT,NOCLKOUT,NOLVP,NOBROWNOUT,PUT

#bit output = PORTA.2
#bit puls1 = PORTA.0
#bit puls2 = PORTA.1
#bit puls3 = PORTA.3
#bit puls4 = PORTA.4
#bit on=PORTA.5

#USE FAST_IO (A)

#use delay(clock=16000000,RESTART_WDT)

      
void main() {
TRISA=0b01111011;

//WPUA=0x3F;
PORT_A_PULLUPS(PIN_A0|PIN_A1|PIN_A2|PIN_A3|PIN_A4|PIN_A5);
//IOCAP=0;
//IOCAF=0b00011011;

setup_oscillator(OSC_16MHZ);

SETUP_ADC_PORTS(NO_ANALOGS);
setup_comparator(NC_NC );
ANSELA=0;

TRISA=0b00011011;
// on=false;

// Setta timer per incremento ogni us
SETUP_TIMER_1(T1_DIV_BY_4|T1_INTERNAL);

// Setup PWM 38Khz su uscita
setup_timer_2(T2_DIV_BY_1, 104, 1);
set_pwm1_duty(210);
SETUP_PWM1(PWM_DISABLED|PWM_OUTPUT);
ENABLE_INTERRUPTS(INT_RA);
ENABLE_INTERRUPTS(GLOBAL);

   while(true){
   restart_wdt();
   TRISA=0b00011011;
   sleep();
   delay_cycles(5);
   }
}


Somebody can suggest me where's the problem ?
Thanks
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Sep 23, 2012 12:44 pm     Reply with quote

Quote:
PORT_A_PULLUPS(PIN_A0|PIN_A1|PIN_A2|PIN_A3|PIN_A4|PIN_A5);

What's the correct way to use that function ? Not that way.
Fabri



Joined: 22 Aug 2005
Posts: 275

View user's profile Send private message

PostPosted: Sun Sep 23, 2012 1:09 pm     Reply with quote

You are right PCM Programmer.
I use now
Quote:

PORT_A_PULLUPS(0b00111011);


I did a bit of confusion !
Smile

Thanks,
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Mon Sep 24, 2012 6:23 am     Reply with quote

Hi,

What's in def12F1501.c? The code you posted does not show an interrupt
handler for INT_RA.... If you enable an interrupt, you MUST have a
corresponding interrupt handler to service it!

John
Fabri



Joined: 22 Aug 2005
Posts: 275

View user's profile Send private message

PostPosted: Mon Sep 24, 2012 6:47 am     Reply with quote

Many Thanks to take a look to my code.

Here's to you def file:
Quote:

#BYTE PORTA = 0x0C
#BYTE TRISA = 0x8C
#BYTE WPUA = 0X20C
#BYTE INTCON = 0x0B
#BYTE ANSELA = 0x18C
#BYTE IOCAP = 0x391
#BYTE IOCAN = 0x392
#BYTE IOCAF = 0x393


I use interrupt and there's handler inside firmware. I didn't post it because the problem was somewhere else and I thought it wasn't important.

In anycase I solved and now the firmware work fine. I did a bit of confusion using PORT_A_PULLUPS() function.

Regards,
Fabri
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