No program response, including config instructions


Closed Thread
Results 1 to 11 of 11
  1. #1

    Default No program response, including config instructions

    I have been testing a program for a 12F683 to drive an RC servo. The compiler is Picbasic Pro ver 3 and both QL 200 and IDE 2 programmers give the same result. The programmed chip does nothing. Reducling the program to a simple loop turning a pin on and off with config setting Clk Out on pin 4, the analyser shows the clk operating at the default 4MHz instead of the config set 8MHz. After many hours and much reading of the datasheet and so on, no result. I sense the problem lies with the configuration statements, but even with only those in the .INFO file there is no response.

    Has anyone a suggestion on what direction to go?

  2. #2
    Join Date
    Sep 2009
    Posts
    752


    Did you find this post helpful? Yes | No

    Default Re: No program response, including config instructions

    First post your code here...
    Clkout is FOSC/4, so OSC is set to 8MHz, you should get 2MHz on pin.

  3. #3


    Did you find this post helpful? Yes | No

    Default Re: No program response, including config instructions

    Analyser shows the clock "ticking" at 1MHz, corresponding to the default 4MHz/4, not the 2MHz I intended to set.

    The analyser shows GPIO.5 going Hi and staying there until the power is turned off.

    Power is 3 x 1.5 AA cells.




    Code is:

    ' Name : 12F683 Simplex Test
    ' Circuit :
    '


    ' Description : PICBASIC Program to Test 12F673 config & set up statements


    ' Circuit :


    ' Hardware :
    '
    ' Target PIC : 12F683
    ' Pins : 8
    ' Compiler : PICBASIC PRO Compiler 2.6
    ' Assembler : MPASM
    '
    ' Oscillator : Internal 1 MHz
    '
    ' ************************************************** ****************************
    ' Comments
    ' Functions:
    ' Inputs



    ' Outputs
    ' Pulde pin GPIO.5




    '
    ' ************************************************** ****************************
    ' Initialise
    ' CONFIG Register
    ' Notes:
    ' Config directive options are in PIC12F683.INFO in C:\PB3\Device_Reference
    ' Format example is:
    ' cfg1 = _INTOSC ; Oscillator
    ' cfg1 = sfg1 $ _WDT_OFF ; Watchdog timer
    ' and so on, thus keeing lines short

    ' config1 for bits 0-7 of the config word, config2 for 8-15

    ' config1
    ' Oscillator
    ' cfg1 = _INTOSCIO ; INTOSCIO osc I/O on RA4/OSC2/CLKOUT
    ; RA5/OSC1/CLKIN

    ' Watchdog timer disabled
    ' cfg1 = cfg1 & _WDT_OFF ;WDT disabled

    ' Power-Up timer enabled
    ' cfg1 = cfg1 & _PWRTE_ON ;PWRT enabled

    ' MCLR Function is internal
    ' cfg1 = cfg1 & _MCLRE_OFF ;MCLR is input, MCLR int tied to VDD

    ' Code Protection OFF
    ' cfg1 = cfg1 & _CP_OFF ;Prog mem code protection is disabled

    ' Data code protection OFF
    ' cfg1 = cfg1 & _CPD_OFF ;Data memory code protection disabled


    ' config bits 8-15
    ' Brown-Out detect enabled
    ' cfg1 = cfg1 & _BOD_ON ;BOR enabled

    ' Internal Switchoover disabled
    ' cfg1 = cfg1 & _IESO_OFF ;Int Ext Switchover mode disabled

    ' Failsafe Clock disabled
    ' cfg1 = cfg1 & _FCMEN_OFF ;Fail-Safe Clock Monitor is disabled


    ' Statement to write CONFIG WORD bits 0-15
    ' __CONFIG _CONFIG1, cfg1

    #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


    __config cfg1

    #ENDCONFIG
    '
    ' Power control - PCON register
    ' Bit 0 Brownout Reset Status - Reset in software after Power-On or BOR
    ' Bit 1 POR Status - Reset in software after Power-On
    ' Bit 2 and 3 unimplemented

    ' Bit 4 Software BOR enable = 1
    PCON.4 = 1

    ' Bit 5 ULPWUE Ultra low power wake up = 0
    PCON.5 = 0

    ' Bit 6 and 7 unimplemented


    ' Define oscillator configuration 8MHz internal bits 6-4 = 111
    OSCCON.6 = 1
    OSCCON.5 = 1
    OSCCON.4 = 1

    ' A to D Off - set bit 0 = 0
    ADCON0 = 0

    ' All comparators off - Bits 0-2 111
    CMCON0.0 = 1
    CMCON0.1 = 1
    CMCON0.2 = 1

    ' Set all pins digital
    ANSEL = 0

    ' Internal Pull-Ups off
    ' OPTION_REG bit 7 = 0
    OPTION_REG.7 = 0

    ' UPU bits 0 -2, 4-5 = 0
    WPU.0 = 0
    WPU.1 = 0
    WPU.2 = 0
    WPU.4 = 0
    WPU.5 = 0

    ' Set TRISIO and outputs to 0 on boot
    ' GPIO.0 = Output
    TRISIO.0 = 0
    GPIO.0 = 0
    'GPIO.5 = Input
    TRISIO.5 = 1

    ' Set unused pins as output (but GPIO.3 must be input)
    TRISIO.1 = 0
    GPIO.1 = 0

    TRISIO.2 = 0
    GPIO.2 = 0

    TRISIO.3 = 1

    TRISIO.4 = 0
    GPIO.4 = 0


    TRISIO.5 = 0
    GPIO.5 = 0

    ' ************************************************** ****************************
    ' Variables etc
    ' Alias's and variables
    PulsePin VAR GPIO.5 ' Output


    ' Counters
    I VAR WORD




    ' ************************************************** ***************************
    ' Main Loop
    MainLoop:


    ' Turn PulsPin On
    PulsePin = 1


    ' Pause
    PAUSE 50


    ' PulsePin Off
    PulsePin = 9


    ' Back to MainLoop
    GOTO MainLoop




    '************************************************* ***************
    End

  4. #4


    Did you find this post helpful? Yes | No

    Default Re: No program response, including config instructions

    Addendum to my post with code included. Line 176 should read "PulsePin = 0" A typo in my transferring the code. Sorry.

  5. #5
    Join Date
    May 2013
    Location
    australia
    Posts
    2,541


    Did you find this post helpful? Yes | No

    Default Re: No program response, including config instructions

    #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
    that's PulsPin =1 for 50000uS an 0 for maybe 2uS , somehow I doubt that's your intent

    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

  6. #6


    Did you find this post helpful? Yes | No

    Default Re: No program response, including config instructions

    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?)

  7. #7
    Join Date
    May 2013
    Location
    australia
    Posts
    2,541


    Did you find this post helpful? Yes | No

    Default Re: No program response, including config instructions

    From your version my suspicion is focused on my missing the DEFINE NO_CLRWDT 1
    your suspicion is totally unfounded . i assumed you had a "valid" reason for not using the WDT
    [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

  8. #8


    Did you find this post helpful? Yes | No

    Default Re: No program response, including config instructions

    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?
    Attached Images Attached Images  

  9. #9
    Join Date
    May 2013
    Location
    australia
    Posts
    2,541


    Did you find this post helpful? Yes | No

    Default Re: No program response, including config instructions

    when I pgm chip with pickit2 I get this.
    the problem is not the code .
    Attached Images Attached Images  
    Warning I'm not a teacher

  10. #10


    Did you find this post helpful? Yes | No

    Default Re: No program response, including config instructions

    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.

  11. #11
    Join Date
    Jan 2012
    Location
    Grid EN19MV
    Posts
    159


    Did you find this post helpful? Yes | No

    Default Re: No program response, including config instructions

    Quote Originally Posted by MillicentBear View Post
    I have been testing a program for a 12F683 to drive an RC servo. The compiler is Picbasic Pro ver 3 and both QL 200 and IDE 2 programmers give the same result. The programmed chip does nothing. Reducling the program to a simple loop turning a pin on and off with config setting Clk Out on pin 4, the analyser shows the clk operating at the default 4MHz instead of the config set 8MHz. After many hours and much reading of the datasheet and so on, no result. I sense the problem lies with the configuration statements, but even with only those in the .INFO file there is no response.

    Has anyone a suggestion on what direction to go?
    Don't know if this will help at all (I haven't read the whole thread yet) but here's one I use on a project of mine. Remember that, in my case, I only have to drive the servo from one extreme to another. I'm not using proportional control at all - just one side or the other.

    But this works - so maybe it'll help.

    Andy

    Code:
    '12F683 MCU USED FOR SERVO CONTROL
    
    #CONFIG
        __config _HFINT_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_ON & _CP_OFF
    #ENDCONFIG
    
    DEFINE OSC 8 'LETS PBP KNOW WE WILL BE RUNNING AT 8MHZ
    
    DISABLE 'NO DEBUG, NO INTERRUPTS
    
    'PIN DEFENITIONS
    'GP0 USED FOR ICSP DATA
    'GP1 USED FOR ICSP CLOCK
    'GP2 USED TO DRIVE SERVO (SIGNAL LINE)
    'GP3 USED FOR MCLR AND ICSP PROGRAMMING
    'GP4 USED FOR LED
    'GP5 USED FOR TRIGGER FROM MAIN PROCESSOR
    
    'SET UP THE SPECIAL REGISTERS
    OSCCON = %01110001  '8MHZ INTERNAL CLOCK USED
    CMCON0 = %00000111 'CIN PINS ARE I/O, COUT PIN IS I/O
    OPTION_REG = 0 'WEAK PULL UPS ARE ENABLED
    TRISIO = %00101011 'GP4 AND GP2 ARE OUTPUTS, THE REST ARE INPUTS 
    ANSEL = 0 'NO ANALOG PORTS - ALL DIGITAL
    WPU = %00100000 'GP5 WEAK PULL UP ENABLED. GP3 WEAK PULL UP AUTOMATICALLY ENABLED
    				'AS THE PIN IS DEFINED AS MCLR
    IOC = 0 'NO INTERRUPT ON CHANGE
    
    'PIN ALIASES
    SERVO VAR GPIO.2
    TRIGGER VAR GPIO.5
    LED VAR GPIO.4
                                                                                                  
    'VARIABLES                                                                                     
    PERIOD_COUNT VAR BYTE 'TO TIME THE 20mS PERIOD
    PULSE VAR BYTE 'PULSE LENGTH IN 100uS INCREMENTS
                                                                                                   
    SERVO = 0 'MAKE SURE NO SIGNAL                                                                                
    LED = 0 'MAKE SURE LED IS OFF
                                                                                                   
    MAIN:
    	DO 'ENDLESS LOOP
    		IF TRIGGER = 1 THEN 'CLOSE THE DAMPER
    			PULSE = 20 '2.0mS PULSE TO SERVO
    			LED = 1 'TURN ON LED
    		ELSE 'OPEN THE DAMPER 
    			PULSE = 10 '1.0mS PULSE TO SERVO
    			LED = 0 'TURN OFF LED
    		ENDIF
    		FOR PERIOD_COUNT = 1 TO 200 '20mS PERIOD
    			IF PERIOD_COUNT > PULSE THEN 'MAKE LINE LOW FOR REST OF 20mS PERIOD
    				SERVO = 0 'MAKE SURE SERVO SIGNAL IS NOW LOW
    			ELSE
    				SERVO = 1 'SERVO SIGNAL LINE HIGH FOR 1.0 OR 2.0mS			
    			ENDIF
    			PAUSEUS 100 '100uS PAUSE		
            NEXT PERIOD_COUNT                                                                            
        LOOP                                                                                       
    END
    "I have noticed that even those who assert that everything is predestined and that
    we can change nothing about it still look both ways before they cross the street"


    -Stephen Hawking

Similar Threads

  1. how to read sine wave response from sensor
    By klaus1 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 23rd April 2011, 21:51
  2. Easy HID Command -Response application
    By ptig185 in forum USB
    Replies: 25
    Last Post: - 22nd September 2010, 20:56
  3. DS1994 memory response problem
    By chika in forum Off Topic
    Replies: 7
    Last Post: - 28th March 2007, 23:35
  4. ad pot fastest response!
    By Alaskanphoenix in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 26th July 2006, 23:21
  5. No Modem response
    By jimboho in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 11th November 2004, 06:58

Members who have read this thread : 2

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts