Addendum to my post with code included. Line 176 should read "PulsePin = 0" A typo in my transferring the code. Sorry.
Addendum to my post with code included. Line 176 should read "PulsePin = 0" A typo in my transferring the code. Sorry.
that's PulsPin =1 for 50000uS an 0 for maybe 2uS , somehow I doubt that's your intent#CONFIG
cfg1 = _INTOSCIO
cfg1 = cfg1 & _WDT_OFF
cfg1 = cfg1 & _PWRTE_ON
cfg1 = cfg1 & _MCLRE_OFF
cfg1 = cfg1 & _CP_OFF
cfg1 = cfg1 & _BOD_ON
cfg1 = cfg1 & _IESO_OFF
cfg1 = cfg1 & _FCMEN_OFF
dgg1 = cfg1 & INTOSC this will never compile
__config cfg1
#ENDCONFIG
MainLoop:
' Turn PulsPin On
PulsePin = 1
' Pause
PAUSE 50
' PulsePin Off
PulsePin = 9
' Back to MainLoop
GOTO MainLoop
try this , I have removed all the code and comments that serve no purpose
Code:' Hardware : ' ' Target PIC : 12F683 ' Outputs ' Pulse pin GPIO.5 #CONFIG cfg1 = _INTOSCIO cfg1 = cfg1 & _WDT_OFF cfg1 = cfg1 & _PWRTE_ON cfg1 = cfg1 & _MCLRE_OFF cfg1 = cfg1 & _CP_OFF cfg1 = cfg1 & _BOD_ON cfg1 = cfg1 & _IESO_OFF cfg1 = cfg1 & _FCMEN_OFF __config cfg1 #ENDCONFIG DEFINE NO_CLRWDT 1 'Forces manual use of CLRWDT since you have wdt is turned off in config DEFINE OSC 8 ;missing ' Define oscillator configuration 8MHz internal bits 6-4 = 111 OSCCON = $70 ' All comparators off - Bits 0-2 111 CMCON0 = 7 ' Set all pins digital ANSEL = 0 ' Set TRISIO and outputs to 0 on boot GPIO = 0 TRISIO = %011111 ; gpio.5 o/p the rest are i/p since only gpio.5 used ' ************************************************** **************************** ' Variables etc ' Alias's and variables PulsePin VAR GPIO.5 ' Output ' ************************************************** *************************** ' Main Loop MainLoop: ' Turn PulsPin On PulsePin = 1 ' Pause PAUSE 50 ' PulsePin Off PulsePin = 0 PAUSE 50 ; I believe to be missing ' Back to MainLoop GOTO MainLoop '************************************************* *************** End
Warning I'm not a teacher
Richard,
Thank you very much for a very helpful reply.
dgg1 was of course a typo - being too clever in the (adjusted) cut & paste process. Ditto for the missing Pause 50. I did intend the pause to be 50mSec - simply for ease of viewing in this "get it going" test version. In the servo drive version the pulse is 1.5 - 2 mSec and a period of 20 mSec.
As I read your version, you have confirmed my suspicion my problem lay in the config and other statements above the program proper start line. My original effort(s) expressed OSCCON, TRISIO and so on in the form you have, but I tried setting one bit at a time to be sure (in my mind) I was not accidentally setting bits I did not intend. I shall reveret to your format.
From your version my suspicion is focused on my missing the DEFINE NO_CLRWDT 1. I did not see that in any of the material fi found on WDT.
Anyway, I shall try this as soon as I can and report back
Thanks again
(PS The comment "This is better than free to air TV is undoubtedly true. Well, I think it is, but the compiler rejected it when accidentally included in the program, so perhaps there is some doubt?)
your suspicion is totally unfounded . i assumed you had a "valid" reason for not using the WDTFrom your version my suspicion is focused on my missing the DEFINE NO_CLRWDT 1
[DEFINE NO_CLRWDT 1 ] simply stops the compiler adding unnecessary CLRWDT commands to the resulting code
and potentially wasting code space .
to get the best possible results from the forum you need to post the actual code you are using {in code tags}
not some hacked up version full of typo's .
when it comes to programing rubbish in ..... rubbish out , and just 1 bit can do it
Richard,
Thanks for your comments. We are not all perfect, but I shall try to do better next time re typos. .
I copied by cut and paste then compiled your code exactly as you sent it.
The result was the same. No reaction from the Pic. Nor from five of its mates. So unless I have a bad batch of Pics, as you say I have one bit of rubbish that is preventing the program working. Since the body of the program is so simple this suggests the rubbish is somewhere above that.
Attached is a sample screen shot from the analyser. The power supply is on channel 7 (Purple) and the expected output on channel 6 (Blue). The trigger is channel 7.
The output shows a single short output pulse when the power comes on, then a delay of about 2.5 seconds before going High. Then nothing until the power is turned off. Collecting a sample for longer is just the same - the shift Low of the output pin just moves out to when the power is turned off.
An suggestions please?
when I pgm chip with pickit2 I get this.
the problem is not the code .
Warning I'm not a teacher
Richard,
Thanks for the prompt reply.
In some ways it is a relief to know it is not the code. That is a big step forward.
As per my first post I had tried two different programmers, both from the same origin. I also tried an older version of MPLAB (which I had had programming success) and a download of the latest version. No success with any combination.
I shall wend my way carefully and methodically through re-installation and settings again, including trying the job on the (retired) 32 bit PC that previously yielded success. All while I wait for delivery of a new programmer I ordered on suspicion.
I really am getting too old for all this. In retirement things are supposed to go smoothly!
Thanks again for your help.
Bookmarks