| View previous topic :: View next topic |
| Author |
Message |
Fabri
Joined: 22 Aug 2005 Posts: 275
|
| Wake-Up on PIC12LF1501 |
Posted: Sun Sep 23, 2012 7:53 am |
|
|
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
|
|
Posted: Sun Sep 23, 2012 12:44 pm |
|
|
| 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
|
|
Posted: Sun Sep 23, 2012 1:09 pm |
|
|
You are right PCM Programmer.
I use now
| Quote: |
PORT_A_PULLUPS(0b00111011);
|
I did a bit of confusion !
Thanks, |
|
 |
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
Posted: Mon Sep 24, 2012 6:23 am |
|
|
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
|
|
Posted: Mon Sep 24, 2012 6:47 am |
|
|
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 |
|
 |
|