CONFIG fOSC = INTIO67 ' Internal oscillator, IO on pins 6 and 7
That's automatically handled by the intosc module for you, and it'll just confuse things when you change it later.
While you're at it, remove the duplicate 'INCLUDE "SetDigitalIO.bas"' statement.
Anyway, the IO setting of PORTA.6 and PORTA.7 have no effect on PORTC.6 and PORTC.7
but when the PIR2 TRIPS, THE PORTC.6 & 7 come on as well but not supposed to
Jerry You wrote the IntOSC .bas Its nice work I was thinking it set's the whole ball of wax.
The sample shows how to use it Nice job.
Code:
device = 18F26K22
clock = 64
// optional - wait for intosc freq stable bit (the module defaults to not waiting)
'#option _INTOSC_IOFS_WAIT = true
include "intOSC.bas"
Rest of the gunk goes here
And a little more
Code:
device = 18F1320
clock = 8
include "IntOSC.bas"
include "USART.bas"
include "EEPROM.bas"
include "Convert.bas"
SetBaudrate(br19200)
Write("Program starting...",13,10)
while true
Write("High",13,10)
delayms(500)
Write("Low",13,10)
delayms(500)
wend
Well here is the whole enchilada at this point in time. The code is supposed to just monitor the battery condition but when the battery voltage goes down to 3.1 the yellow LOW Battery led comes on BUT portc.6 & 7 decide to come on as well.
Seriously thinking of eliminating the HLVD section but portc has no connections to portc ??
Have a second assembled board to test present code on,
MrDEB, do you ever proofread your posts after you click the button? You still don't get code tags (or you just refuse to indent to help people understand your code), and in the above case, you didn't even include the code you said you did. You expect people to take time to help you, but your can't even check to see that what you posted makes sense.
basic code
DEVICE = 18F43k20 ' Tell the compiler what chip we are using
CLOCK = 20 ' Tell the compiler what we will be setting the clock to (Mhz)
CONFIG MCLRE = OFF
CONFIG fOSC = INTIO67 ' Internal oscillator, IO on pins 6 and 7
CONFIG boren = off
'INCLUDE "INTOSC8.bas"
'INCLUDE "InternalOscillator.bas"
INCLUDE "SetDigitalIO.bas"
INCLUDE "Utils.bas"
DIM x AS BYTE
DIM Time AS LONGWORD
DIM Et_time AS LONGWORD
//INPUTS
DIM Mexi AS portA.0
DIM Bullit AS portA.1
DIM Master_Swt AS portE.0
DIM Position1 AS portB.0
DIM Position2 AS portB.1
DIM Position3 AS portB.2
DIM Position4 AS portB.3
DIM Position5 AS portB.4
DIM Position6 AS portB.5
DIM Position7 AS portB.6
DIM Position8 AS portB.7
DIM Position9 AS portD.0
DIM Position10 AS portD.1
//TIME SELECT
DIM Time1 AS portA.2
DIM Time2 AS portA.3
DIM Time3 AS portA.4
DIM Time4 AS portA.5
//OUTPUTS
//PLAYER POSITIONS leds
DIM pLAYER1 AS PORTC.0
DIM pLAYER2 AS PORTC.1
DIM pLAYER3 AS PORTC.2
DIM pLAYER4 AS PORTC.3
DIM pLAYER5 AS PORTC.4
DIM pLAYER6 AS PORTC.5
DIM pLAYER7 AS PORTC.6
DIM pLAYER8 AS PORTC.7
DIM pLAYER9 AS PORTD.2
DIM pLAYER10 AS PORTD.3
//TIMING LEDS
DIM Green1 AS portD.4
DIM Green2 AS portD.5
DIM Yellow1 AS portD.6
DIM Yellow2 AS portD.7
DIM MST_LED AS PORTE.1
//HLVD LEDS
DIM Low_bat AS portA.6
DIM Pwr_on AS portA.7
SUB HLVD()
HLVDCON =%00011100 'see section 22.0 for setup and table 26-4 for voltage setting
'set to 4 volts in this case 11100 = 3.1 volts
PIR2.bits(2) = 0
IF PIR2.bits(2) = 1 THEN 'check HLVD interrupt
Green1= 0 'LED = ON
PIR2.bits(2) = 0 'clear HVLD interrupt
ELSE
Green1= 1 'LED = OFF
END IF
TOGGLE (Pwr_on)
DELAYMS(50)
END SUB
//HLVDCON =%00011100 'see section 22.0 for setup and table 26-4 for voltage setting
'set to 4 volts in this case 11100 = 3.1 volts
//PIR2.bits(2) = 0
{
portC.0 to C.7 = blue player leds players 1 to 8
portD2 & 3 = blue player leds players 9 to 10
portA.6 & 7 = HLVD A.6 = LOW battery A.7 = Pwr on
portD.4 & 5 = greem leds timming
portD.6 & 7 = Yellow leds
portE.1 = red master switch led
}
SUB ET ()
pLAYER1=1
DELAYMS(1000)
TOGGLE(pLAYER1)
DELAYMS(500)
IF Time1=0 THEN Et_time=500 END IF //port A.2
IF Time2=0 THEN Et_time=750 END IF //port A.3
IF Time3=0 THEN Et_time=1000 END IF //port A.4
IF Time4=0 THEN Et_time=1500 END IF //port A.5
END SUB
//THIS routine cycles the LEDS off/on as per ET select routine
SUB Time_Countdown() //1000ms = 1 second x 5 Green, Green, Yellow, Yellow, RED
FOR x = 0 TO 7 //2500ms total on time1
Green1=0 //3750ms time2
DELAYMS(1000) //5000ms time3
Green1=1 //7500ms on time4
DELAYMS(1000)
NEXT
MST_LED= 1
DELAYMS(500)
TOGGLE(MST_LED)
DELAYMS(300)
END SUB
There was stupid me thinking you were trying to build a flashing led. i.e go back to basics and learn... Why does the led have to flash? low battery led on. Jonsea dont take this the wrong way, but your not helping, nothing will change until you change it.
Ok swordfish you dosnt make you read the datasheet, but i advocate reading them so people get how the chip works. In this case i would advocate Mr Deb comments all code by line then at the start and end of each block of code, i would insist he reads the codes and comments exactly what his block of code has done. He isnt going any other way, sorry but i dissagree with this kind of constant spoon feeding the same way i would to a healthy 12 year old still being fed on the boob.
I am not being nasty, actually i am trying to help as its starting to look like we are the problem not the solution. If this is that mouse trap, you aint half got some nerve Mr Deb
In my earlier days when I had a bug, I'd describe how the code worked to anyone (Teddy, coffee cup etc.) that would listen (or not). The act of describing how code works will (almost always) make you realise where the bug is. I believe this method is now called "Rubber Ducking".
8MHZ is burning some juice for a battery powered mouse trap. why do you need that kind of speed? Ok its 4 cycles but that is still really fast for this kind of thing. Also........ok iwill shut up now
In my earlier days when I had a bug, I'd describe how the code worked to anyone (Teddy, coffee cup etc.) that would listen (or not). The act of describing how code works will (almost always) make you realise where the bug is. I believe this method is now called "Rubber Ducking".
Causes problems Mike, i used to do that with my sister while she gurgled in her cot, now she wants access to my parts bin!! I didnt drink coffee then and didnt have a teddy!! Rod for my own back lol
Actually it was you who told me to indent ( i still dont get that!) and comment the code line by line to start with, i kind of comment blocks now but it works
IF Position1 = 0 THEN
TOGGLE(pLAYER1)
DELAYMS(50)
ELSE // you can only get here if Position1 = 1 already, so there's no point in this ELSE code
Position1 = 1 // anyway, YOU CAN'T WRITE TO AN INPUT PIN
Do you see a pattern? What do you expect to happen when you write to a pin that's set as an input?
It's nice after all this you're not even using the INTOSC.BAS module!
By the way, 'CLOCK=20' is invalid for the internal osc... intosc.bas would have told you this had you used it
Try and think of a input pin being a read pin and a output pin being a write pin. Great mouse trap BTW, i guess it took a while to slip in seeing as you declared to not only have made it better but it was working.
Any known issues with SF and win 8.1? my system refuses point blank to install it
Does anyone actually approve forum applications at SF? i joined 5-6 weeks ago and still not approved! Not even sure i can remember the name i used now lol
Its the free version, i also couldnt get the LCD character add on program to install, it said i needed a updated file that i clearly done, i even followed the link to download the MS files it wanted . Shame i cant find a simple program that walks me through using this.
Could be me however, i am so used to ARM and pics etc, and different IDE's, It gets confusing. I want to use the Junebug with SF
Jon found a typing error in post #50
as for writing to an input I am in error but then I am aware of what the pin is supposed to be. Will take the errors out.
Not using it?? INTOSC.BAS module! after I inserted it into the code the timing work great. Just need to adjust the button debounce as the Leds start blinking when pressing desired button
I will add explanations to each line of code. As for the ELSE statement in # 50, have seen this in lots of code examples. not really needed but.
I tested a second board and with the HLVD module activated, the portC. 6 & 7 are enabled when the PIR2.bits(2) = 1 trip point is 3.1 volts.