Program not running on 16F88


+ Reply to Thread
Results 1 to 3 of 3

Hybrid View

  1. #1
    Join Date
    Jul 2024
    Posts
    4

    Default Program not running on 16F88

    Greetings all,

    I purchased PBP3 a few months ago and have been able to write a few programs on my own. I have been using Microcode Studio to compile and a Pickit 4 to transfer the HEX files to the MCUs.
    However, this time i'm facing an issue that i'm not being able to understand.
    I already searched the forum but could not find a solution.

    Currently I'm checking some of the amazing examples of Mr. Darrel Taylor. I loaded a 16F88 MCU with the MIBAM example but I cannot get any LEDs to light up.
    I added an on/off startup LED indication to test the programming and that LED works...but not the scan effect from the MIBAM code.


    Here's the code i'm using:

    Code:
    
    
    #CONFIG
    		__config  _CONFIG1, _WDT_OFF & _FOSC_INTOSCIO & _MCLRE_OFF & _CP_OFF  & _LVP_OFF
    #ENDCONFIG
    
    
    '*****************************************************************************
    'CONFIGURATION
    
    
    'PIE1=0
    'PIE2=0
    'PCON=%11111111
    'EECON1=0
    CCP1CON=0 		' Disable CCP Module
    CVRCON=0
    
    
    CMCON=7 	         ' analog comparators off
    OPTION_REG.7=1      	' Disable Pull-Ups
    
    
    OSCTUNE=%00000000
    OSCCON=%01111000	'16f88 - 8Mhz 
    
    
    TRISA = %00000000				
    TRISB = %00000000
    
    
    DEFINE OSC 8
    
    
    '*****************************************************************************
    
    
    ;____[ For 12F/16F only - Interrupt Context save locations]_________________
    wsave       var byte    $20     SYSTEM  ' location for W if in bank0
    ;wsave       var byte    $70     SYSTEM  ' Alternate save location for W 
                                            ' if using $70, comment out wsave1-3
    ' --- IF any of these next three lines cause an error ?? -------------------
    '       Comment them out to fix the problem ----
    ' -- The chip being used determines which variables are needed -------------
    wsave1      VAR BYTE    $A0     SYSTEM      ' location for W if in bank1
    wsave2      VAR BYTE    $120    SYSTEM      ' location for W if in bank2
    wsave3      VAR BYTE    $1A0    SYSTEM      ' location for W if in bank3
    '---DO NOT change these-----------------------------------------------------
    ssave       VAR BYTE    BANK0   SYSTEM      ' location for STATUS register
    psave       VAR BYTE    BANK0   SYSTEM      ' location for PCLATH register
    ' --------------------------------------------------------------------------
    disable debug
    ;---------------------------------------------------------------------------
    
    
    
    
    '*****************************************************************************
    
    
    'VARiables
    
    
    TIM1		VAR     WORD	'
    TIM2		VAR		WORD	'
    TIM3		VAR		WORD	'
    TIM4		VAR		WORD
    DIRLED		VAR		BYTE	
    CNT		    VAR		WORD
    
    
    KM		    VAR    		WORD	'POWER-ON COUNTER
    
    
    LINE1      	CON   		$80   
     
    '*****************************************************************************
    'PORTS & PINS 
    
    
    A2	 	VAR	PORTA.2	'OUT LED
    b1	 	VAR	PORTb.1	'OUT LED
    
    
    '*****************************************************************************
    
    
    
    
    
    
    ;----[ MIBAM Setup ]--------------------------------------------------------
    'BAM_FREQ  CON 100                   ; Desired Refresh rate Limit
    ;ScopeSync VAR PORTB.0               ; if declared, generates sync for OScope
    DEFINE BAM_INFO 1                   ; use to display MIBAM results
    
    
    BAM_COUNT CON 3                     ; How many BAM Pins are used?
    INCLUDE "MIBAM.pbp"                  ; Mirror Image BAM module
    
    
    BAM_DUTY  VAR BYTE[BAM_COUNT]
      LED1    VAR BAM_DUTY[0]           ; group them in an array for easy access
      LED2    VAR BAM_DUTY[1]           ; with FOR loops etc.
      LED3    VAR BAM_DUTY[2] 
      LED4    VAR BAM_DUTY[3] 
      LED5    VAR BAM_DUTY[4] 
      LED6    VAR BAM_DUTY[5] 
      LED7    VAR BAM_DUTY[6] 
      LED8    VAR BAM_DUTY[7] 
    
    
    
    
    ASM
    BAM_LIST  macro                     ; Define PIN's to use for BAM
         BAM_PIN (PORTB,0, LED1)        ;   and the associated Duty variables
         BAM_PIN (PORTB,1, LED2)
         BAM_PIN (PORTB,2, LED3)
    ;     BAM_PIN (PORTB,3, LED4)
    ;     BAM_PIN (PORTB,4, LED5)
    ;     BAM_PIN (PORTB,5, LED6)
    ;     BAM_PIN (PORTB,6, LED7)
    ;     BAM_PIN (PORTB,7, LED8)
      endm
      BAM_INIT  BAM_LIST                ; Initialize the Pins
    ENDASM
       
    
    
    '*****************************************************************************
    CLEAR
    '*****************************************************************************
    
    
    ;_________________________________________________
    Speed       CON 2'6         ; Smaller = Faster
    TracerSpeed CON 5'15        ; Smaller = Faster Left/Right
    Brightness  CON 200       ; Tracers DutyCycle
    DrainSpeed  CON 30        ; Smaller = Shorter Trail
    
    
    Idx         VAR BYTE
    LoopCount   VAR BYTE
    NextLED     VAR BYTE
    TraceDIR    VAR BIT
    
    
      TraceDIR  = 0
      LoopCount = 0
      NextLED   = 0
     
     startup: 
      
    for CNT	=1 to 2     'for power on test purposes
    high b1
    pause 1000
    low b1
    pause 1000
    
    
    next CNT	
    
    
     '*****************************************************************************
        
    Main:
    
    
        if LoopCount = TracerSpeed then             ; __[ Cylon/Kitt Scanner ]__
          LoopCount = 0
          BAM_DUTY(NextLED) = Brightness
          if TraceDIR then                          ; if scanning left
            NextLED = NextLED - 1
            if NextLED = 0 then TraceDIR = 0
          else                                      ; else scanning right
            NextLED = NextLED + 1
            if NextLED = BAM_COUNT-1 then TraceDIR = 1
          endif
        endif
        
        FOR Idx = 0 to BAM_COUNT - 1                ; Drain all dutycycles
           IF BAM_DUTY(Idx) > 0 then
               BAM_DUTY(Idx) = BAM_DUTY(Idx)*DrainSpeed/(DrainSpeed+1)
           ENDIF
        NEXT Idx
        pause Speed
        LoopCount = LoopCount + 1
        
        high a2
        
    GOTO Main
    Can anyone help troubleshoot this issue?

    I thank you in advance

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    2,505


    Did you find this post helpful? Yes | No

    Default Re: Program not running on 16F88

    Executing a Clear after the include file certainly doesn't help

    get rid of this
    '************************************************* ****************************
    CLEAR
    '************************************************* ****************************


    Code:
    CCP1CON=0 		' Disable CCP Module
    CVRCON=0
    
    
    
    
    CMCON=7 	         ' analog comparators off
    OPTION_REG.7=1      	' Disable Pull-Ups
    
    
    
    
    OSCTUNE=%00000000
    OSCCON=%01111000	'16f88 - 8Mhz
    Should be [comparator/ccp etc are off by default & bit 3 of OSCCON is read only ]

    Code:
    ANSEL=0
    OPTION_REG.7=1      	' Disable Pull-Ups
    OSCCON=%01110001	'16f88 - 8Mhz
    BAM_COUNT CON 3 ; will not do much or look like a cylon in cylon demo
    Warning I'm not a teacher

  3. #3
    Join Date
    Jul 2024
    Posts
    4


    Did you find this post helpful? Yes | No

    Default Re: Program not running on 16F88

    Greetings Richard,

    thank you for your help.

    I tested your recommendations and the thing that worked was removing the clear statement.
    You were correct, the clear line was not doing anything good.

    Once I removed it, it started working as expected.

    Thanks again.

Similar Threads

  1. Replies: 4
    Last Post: - 10th May 2022, 15:58
  2. Replies: 8
    Last Post: - 28th January 2014, 14:21
  3. Replies: 1
    Last Post: - 23rd May 2009, 09:22
  4. ME Labs Loader program - file for 16f88
    By Ken Howell in forum Off Topic
    Replies: 0
    Last Post: - 24th January 2007, 03:12
  5. Startup power higher than while program running - why?
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 11th December 2006, 10:25

Members who have read this thread : 14

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