I have some new 10F320's that I'm playing with. I can't get them to come out of SLEEP with MCLRE like I can on the 200's. Simple program that I snagged from another post to try. What am I missing? Do I need to update WPUEN and WPUA3? GIE?
Power on, battery, LED lights 1 second, out, sleep, never wakes with change on MCLRE/porta.3
Any insight?
Thanks,
CaptnJB
~~~~~
;Chip Settings
chip 10F320,4
config OSC=INTOSC, WDTE=OFF, MCLRE=OFF
;Interrupt Handlers
On Interrupt ExtInt0 Call wake_up
dir gpio.0 out
dir GPIO.3 IN
main:
set gpio.0 on
wait 1 s
set gpio.0 off
wait 1 s
asm sleep
nop
goto main
Sub wake_up
End Sub
Last edit: Anobium 2015-09-24
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hey Anobium and whoever else may have some insight,
I had already changed the FreeRAM, but I did change the RAM= and it is still the same. It will not wake from SLEEP. I have tried MCLRE (GPIO.3) through a 10k and with a jumper to Vdd. This circuit is going to be powered by a 3v lithium battery so I don't have any caps in the circuit.
I have tried using TRIS and option code as well, I just can't get this thing to wake up.
Can anyone else replicate?
Thanks,
CaptnJB
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I even changed GPIO (10F2XX) to PORTA.X to be more compatible. The LED lights for one second as coded either way, then sleep. Then it doesn't wake again.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Try directly modifying the interrupt using assembler.
Add these lines before the sleep instruction.
I have done this in the code below
bsf 0bx0,7 ' force global interrupts on
bsf 0bx0,4 ' force external interrupt, portA.2
bcf 0bx0,1 ' force clear external interrupt flag
bcf 0bx0,0 ' force clear interrupt-on-change flag
;Chip Settings
#chip 10F320,4
#config OSC=INTOSC, WDTE=OFF, MCLRE=OFF
;Interrupt Handlers
On Interrupt ExtInt0 Call wake_up
dir gpio.0 out
dir GPIO.3 IN
main:
set gpio.0 on
wait 1 s
set gpio.0 off
wait 1 s
bsf 0bx0,7 ' force global interrupts on
bsf 0bx0,4 ' force external interrupt, portA.2
bcf 0bx0,1 ' force clear external interrupt flag
bcf 0bx0,0 ' force clear interrupt-on-change flag
asm sleep
nop
goto main
Sub wake_up
End Sub
---
Last edit: Rikki 2015-10-01
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have some devices coming from Microchip. Should be here Tuesday, next week.
I have just tested on 16f1938 and everything works as expected. I have tested on a scope to ensure I get the correct LED timing as shown in the program below. I have made one change to ensure the oscillator is operational.
This is working here. Chris was 4500klm away, but with the power of the internet and chat! Between us it is resolved. But, Chris found the error. WINNER!!!!
;Chip Settings
#chip 10F320,4
#config OSC=INTOSC
;Interrupt Handlers
On Interrupt ExtInt0 Call wake_up
ANSELA = 0
dir gpio.0 out
dir GPIO.2 IN
main:
set gpio.0 on
wait 1 s
set gpio.0 off
wait 1 s
asm sleep
nop
goto main
Sub wake_up
End Sub
Last edit: Anobium 2015-10-07
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello again, I apologise in advance for adding something which might appear to be very simple to a high level thread but this is giving me one hell of a headache and here is the only place on the forum I can find any mention relative to the problem I have.
I have written some code for a latching switch using my favourite little beastie 10F0202 and I am really pleased with it being one of my more successful projects. As it is a battery powered project it consumes some 320µA in standby which is quite frugal but what I want to do is send it to sleep.
Inserting the instruction ‘SLEEP’ after a timeout works a treat reducing the current consumption down to a mere 6 µA which is absolutely wonderful.
The problem I have is that the chip will not waken on an input but appears to fall into a coma to where only a hard power on reset will bring it back to life.
I have read somewhere that I need to read the state of all the ports, but that is above my programming skills.
From the four available ports I have GPIO 0, 1 and 3 set as outputs and GPIO3 set as an input.
Any help would be really appreciated as I cannot find anything relative to using SLEEP anywhere apart from on the Microchip 10F202 Programming Guide, but that talks in a level of understanding well above mine.
Many thanks in advance
Keith
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sorry, I'm having one of those 'Senior Moments' I don't seem to be able to find the GCB Version Number.
All I get when I compile at the bottom of the page in the dialogue box is:
Hey All,
I have some new 10F320's that I'm playing with. I can't get them to come out of SLEEP with MCLRE like I can on the 200's. Simple program that I snagged from another post to try. What am I missing? Do I need to update WPUEN and WPUA3? GIE?
Power on, battery, LED lights 1 second, out, sleep, never wakes with change on MCLRE/porta.3
Any insight?
Thanks,
CaptnJB
~~~~~
;Chip Settings
chip 10F320,4
config OSC=INTOSC, WDTE=OFF, MCLRE=OFF
;Interrupt Handlers
On Interrupt ExtInt0 Call wake_up
dir gpio.0 out
dir GPIO.3 IN
main:
set gpio.0 on
wait 1 s
set gpio.0 off
wait 1 s
asm sleep
nop
goto main
Sub wake_up
End Sub
Last edit: Anobium 2015-09-24
Can you please edit the 10f320.dat file please?
There is an error in the datasheet.
Change as follows.
to
and also,
to
Last edit: Anobium 2015-09-24
Hey Anobium and whoever else may have some insight,
I had already changed the FreeRAM, but I did change the RAM= and it is still the same. It will not wake from SLEEP. I have tried MCLRE (GPIO.3) through a 10k and with a jumper to Vdd. This circuit is going to be powered by a 3v lithium battery so I don't have any caps in the circuit.
I have tried using TRIS and option code as well, I just can't get this thing to wake up.
Can anyone else replicate?
Thanks,
CaptnJB
N/C <=== PIN1 PIN8 ==> 10K ==> Switch ==> Vdd
Vdd <=== PIN2 PIN7 ==> Vss
N/C <=== PIN3 PIN6 ==> N/C
N/C <=== PIN4 PIN5 ==> + LED - ==> Vss
Vdd +3V
Vss GND/NEG
Unless I am missing something RA2 is the External interrupt.
N/C <=== PIN3 should be connect to something to raise the external event.
Sorry it took so long. Just now testing it out. won't wake up using any pin.
I've set GIE 0, WPUA2 1, WPUEN 0 as well. I'm lost here. Any ideas?
Please post a zip of your source and the asm as an attachment. I can look at this later this week.
The code is above and the ASM is generated by GCBasic. No changes other than what I have tried with no success.
;Chip Settings
chip 10F320,4
config OSC=INTOSC, WDTE=OFF, MCLRE=OFF
;Interrupt Handlers
On Interrupt ExtInt0 Call wake_up
dir gpio.0 out
dir GPIO.3 IN
main:
set gpio.0 on
wait 1 s
set gpio.0 off
wait 1 s
asm sleep
nop
goto main
Sub wake_up
End Sub**
I even changed GPIO (10F2XX) to PORTA.X to be more compatible. The LED lights for one second as coded either way, then sleep. Then it doesn't wake again.
Hi
Try directly modifying the interrupt using assembler.
Add these lines before the sleep instruction.
I have done this in the code below
bsf 0bx0,7 ' force global interrupts on
bsf 0bx0,4 ' force external interrupt, portA.2
bcf 0bx0,1 ' force clear external interrupt flag
bcf 0bx0,0 ' force clear interrupt-on-change flag
Last edit: Rikki 2015-10-01
I have some devices coming from Microchip. Should be here Tuesday, next week.
I have just tested on 16f1938 and everything works as expected. I have tested on a scope to ensure I get the correct LED timing as shown in the program below. I have made one change to ensure the oscillator is operational.
~~~~~
#chip 16f1938, 4
#config Osc = intOSC, MCLRE_ON, PLLEN_OFF, VCAPEN_OFF
;Interrupt Handlers
On Interrupt ExtInt0 Call wake_up
dir porta.0 out
dir portb.0 IN
main:
repeat 4
asm sleep
nop
wait while OSCSTAT = 0
goto main
Sub wake_up
set porta.0 on
wait 2 s
End Sub
Last edit: Anobium 2015-10-03
Chris Rogers resolved this!
add in your code.
ANSELA = 0
This is a feature we will have to resolve in the next release.
This is working here. Chris was 4500klm away, but with the power of the internet and chat! Between us it is resolved. But, Chris found the error. WINNER!!!!
Last edit: Anobium 2015-10-07
Please try this file here place the file in your GCB@Syn\GreatCowBasic\include\lowlevel folder. This should over write an existing file.
Then, please remove ANSELA = 0 from the source and test.
Let us know.
I just tested the following. I have added the powermgt also.
~~~~~
;Chip Settings
chip 10F320,4
config OSC=INTOSC
;Interrupt Handlers
On Interrupt ExtInt0 Call wake_up
VREGPM1 = 1
dir gpio.0 out
dir GPIO.2 IN
main:
set gpio.0 on
wait 1 s
set gpio.0 off
wait 1 s
asm sleep
nop
goto main
Sub wake_up
End Sub
would MCLRE=off alter it?
We have found a bug. The download should fix the issue.
The issue was the ADCON0 register was called ADCON on the 10F32x, which meant the tests of set the ANSEL was failing in system.h.
MCRLE does not seeem to have impact on the test rig I have here. I did get the chips through yesterday, very fast.
I have done some basic current checks and the current is reduced during sleep.
Hello again, I apologise in advance for adding something which might appear to be very simple to a high level thread but this is giving me one hell of a headache and here is the only place on the forum I can find any mention relative to the problem I have.
I have written some code for a latching switch using my favourite little beastie 10F0202 and I am really pleased with it being one of my more successful projects. As it is a battery powered project it consumes some 320µA in standby which is quite frugal but what I want to do is send it to sleep.
Inserting the instruction ‘SLEEP’ after a timeout works a treat reducing the current consumption down to a mere 6 µA which is absolutely wonderful.
The problem I have is that the chip will not waken on an input but appears to fall into a coma to where only a hard power on reset will bring it back to life.
I have read somewhere that I need to read the state of all the ports, but that is above my programming skills.
From the four available ports I have GPIO 0, 1 and 3 set as outputs and GPIO3 set as an input.
Any help would be really appreciated as I cannot find anything relative to using SLEEP anywhere apart from on the Microchip 10F202 Programming Guide, but that talks in a level of understanding well above mine.
Many thanks in advance
Keith
Hello Mike.
What version of GCB please? Can you attach your code?
Hello, is the reply to me? If so I'm using SynWrite 6.5. v1030
Keith
@Kieth. Sorry. What version of GCB? the version is shown when you compile your program. Is it v0.94?
Sorry, I'm having one of those 'Senior Moments' I don't seem to be able to find the GCB Version Number.
All I get when I compile at the bottom of the page in the dialogue box is:
20:39:55 G@Stool-COMPILE/ASSEMBLE, processing D:\GCB@Sym\G@Stools\makeHEX.bat
@@Keith. What is date and time of gcbasic.exe?
17/12/2014 22:35