okay, so I have gone as far as I need with the 12F508 for the moment. I now want to move ont something a bit more adventurious with a 16F676. Once again I am being either as thick as rhino dung, or this thing is bugga'd
I just want it to flash a LED on and Off, but it doesn't want to play
Hi,
Just after Set LED On , you write goto Main
But just after Main you write Set LED Off
So, You'll put Wait 500 ms or any delay just after Main or after Set LED On otherwise you'll not switch on the LED !
Regards
GC
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Well spoted… Thank you, but it still doesn't want to work. I think I'm missing somthing in the CONFIG or Init Sys which is preventing it from running the loop.
Grrr,,,,, Don't you just love it when things won't work !
Might as well go -
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
i have resolved my issues now, the problem was very, very basic. the golden rule, There was no Loop instruction.
I shall now consider myself severely reprimanded and detain myself indoors for the evening instead of attending my usual Friday evening ritual which involves converting copious amounts Ale, Wine and Spirits in urine.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Unfortunately, I don’t have sufficient experience in programming these little beasties to answer or argue otherwise. What I do know is that after nearly 2 days of tedious g hair pulling and not getting anywhere, when I compile and program a 16F676 with this:
;Chip Settings
#chip 16F676,4
#config CP=OFF, BODEN=OFF, MCLRE=OFF, WDT=OFF, OSC=INTRC_OSC_NOCLKOUT
I think you can't use PortA as a digital port because ANSEL register is set to 255 after reset ( see 7.0 ANALOG-TO-DIGITAL
CONVERTER (A/D) MODULE (PIC16F676 ONLY).
So AN0 to AN7 are in analog mode . Try to do ANSEL=0 to set AN0 to AN7 in digital mode .
I don't know if GCBasic automatically sets ANSEL register to 0.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
okay, so I have gone as far as I need with the 12F508 for the moment. I now want to move ont something a bit more adventurious with a 16F676. Once again I am being either as thick as rhino dung, or this thing is bugga'd
I just want it to flash a LED on and Off, but it doesn't want to play
The Code I am using is:
;Chip Settings
#chip 16F676,4
#config CP=OFF, BODEN=OFF, MCLRE=OFF, WDT=OFF, OSC=INTRC_OSC_NOCLKOUT
;Defines (Constants)
#define LED PORTA.5
dir PORTA b'000100'
'make PORTA,2 a digital input
dir PORTC b'000000'
'make PORTC all digital Outputs
Main:
Set LED Off
Wait 500 ms
Set LED On
goto Main
Will someone kindly point out the error of my ways, or have me put to sleep!
Thanks in anticipation
Hi,
Just after Set LED On , you write goto Main
But just after Main you write Set LED Off
So, You'll put Wait 500 ms or any delay just after Main or after Set LED On otherwise you'll not switch on the LED !
Regards
GC
Well spoted… Thank you, but it still doesn't want to work. I think I'm missing somthing in the CONFIG or Init Sys which is preventing it from running the loop.
Grrr,,,,, Don't you just love it when things won't work !
Might as well go -
Is MCLR well connected to VDD with a resistor and capacitor as recommanded in datasheet ( 9.3.1)?
i have resolved my issues now, the problem was very, very basic. the golden rule, There was no Loop instruction.
I shall now consider myself severely reprimanded and detain myself indoors for the evening instead of attending my usual Friday evening ritual which involves converting copious amounts Ale, Wine and Spirits in urine.
I don't understand ! Goto main is a loop instruction !
Unfortunately, I don’t have sufficient experience in programming these little beasties to answer or argue otherwise. What I do know is that after nearly 2 days of tedious g hair pulling and not getting anywhere, when I compile and program a 16F676 with this:
;Chip Settings
#chip 16F676,4
#config CP=OFF, BODEN=OFF, MCLRE=OFF, WDT=OFF, OSC=INTRC_OSC_NOCLKOUT
;Defines (Constants)
#define RX_Input PORTA.2
#define LED PORTA.5
#define LED_1 PORTC.5
dir PORTA b'000100'
'make PORTA,2 a digital input
dir PORTC b'000000'
Do Forever
PulseOut PORTC.2, 500 ms
Wait 500 ms
Loop
It Works!
The clue came from going back to basics with the GC Help Wiki…
I think you can't use PortA as a digital port because ANSEL register is set to 255 after reset ( see 7.0 ANALOG-TO-DIGITAL
CONVERTER (A/D) MODULE (PIC16F676 ONLY).
So AN0 to AN7 are in analog mode . Try to do ANSEL=0 to set AN0 to AN7 in digital mode .
I don't know if GCBasic automatically sets ANSEL register to 0.