PIC16F345 and DT_INTS-14


+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2013
    Posts
    3

    Default PIC16F345 and DT_INTS-14

    Hi,

    Is there DT_INTS-14 that works with PIC16F345 ? I have tried to modify DT_INTS-14...changed few obvious difference's in #defines for timers 0/1/2 and and few more but LED blinky does not work. Is it possible to do it or 16F15xx are too much different ? By the way, code compiles, LCD out works but LED is not blinking.

    Thank you,

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


    1 out of 1 members found this post helpful. Did you find this post helpful? Yes | No

    Default Re: PIC16F345 and DT_INTS-14

    a pic16f345 is not a valid pic type, perhaps a simple schematic of your actual setup is called for and
    then why don't you post the code you have tried. if you don't want to post the complete project then
    aim to post the simplest compliable program that shows the problem. code snippets generally
    don't cut it, we need to see the config settings, osc speed, var declarations, port settings etc....
    [use code tags] please, if you don't know how to do that then read the faq
    Warning I'm not a teacher

  3. #3
    Join Date
    Mar 2013
    Posts
    3


    Did you find this post helpful? Yes | No

    Default Re: PIC16F15345 and DT_INTS-14

    Sorry, it is PIC16F15345. Attached is modified DT_INTS-14 but does not work.

    Code:
    '
    DISABLE DEBUG
    #CONFIG
        __config _CONFIG1, _FEXTOSC_OFF & _RSTOSC_HFINT32 & _CLKOUTEN_OFF & _CSWEN_OFF & _FCMEN_OFF
        __config _CONFIG2, _MCLRE_ON & _PWRTE_ON & _LPBOREN_OFF & _BOREN_ON & _BORV_LO & _ZCD_OFF & _PPS1WAY_OFF & _STVREN_ON
        __config _CONFIG3, _WDTCPS_WDTCPS_11 & _WDTE_OFF & _WDTCWS_WDTCWS_6 & _WDTCCS_HFINTOSC
        __config _CONFIG4, _BBSIZE_BB512 & _BBEN_OFF & _SAFEN_OFF & _WRTAPP_OFF & _WRTB_OFF & _WRTC_OFF & _WRTSAF_OFF & _LVP_OFF
        __config _CONFIG5, _CP_OFF
    #ENDCONFIG
    '           
    OSCFRQ = %101                ' 16mhz
     DEFINE OSC 16  
    ' lcd setup
     DEFINE lcd_lines 4         
     DEFINE lcd_commandus 1500    
     DEFINE lcd_dataus 44
     DEFINE LCD_DREG PORTB        
     DEFINE LCD_DBIT 4            
     DEFINE LCD_RSREG PORTC       
     DEFINE LCD_RSBIT 7           
     DEFINE LCD_EREG PORTC       
     DEFINE LCD_EBIT 6            
    '
    '-------------------- I/O ------------------------------------------------------
    ' 
      TRISC.4=1            ' input TASTER
      TRISC.5=0            ' output LED1 
      ANSELA = %000000     ' ADC off all
      ANSELB = %00000000   ' 
      ANSELC = %00000000   ' 
    '
    '*******************************************************************************
    ''************************* DT_INTS-14 *****************************************
    '
    INCLUDE "DT_INTS-14_16F15345-A.bas"     ' Base Interrupt System
    INCLUDE "ReEnterPBP.bas"                ' Include if using PBP interrupts
    '
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler   TMR1_INT,  _ToggleLED1,   PBP,  yes
        endm
        INT_CREATE               ; Creates the interrupt processor
    ENDASM
    '
    T1CON = $31                ; Prescaler = 8, TMR1ON
    @ INT_ENABLE  TMR1_INT     ; enable Timer 1 interrupts
    '
    '-------------------------------------------------------------------------------
    ;-- Place a copy of these variables in your Main program -------------------
    ;--   The compiler will tell you which lines to un-comment                --
    ;--   Do Not un-comment these lines                                       --
    ;---------------------------------------------------------------------------
    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 wsave1-3
    '
    ' --- IF any of these three lines cause an error ?? ------------------------
    '       Comment them out to fix the problem ----
    ' -- Which variables are needed, depends on the Chip you are using -- 
     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
    '-------------------------------------------------------------------------------
    '
    '*************************** PIN NAMES ***************************************** 
      TASTER     VAR portC.4       '  
      LED1       VAR portC.5   
    '
    ' test program for PIC16F15345 with DT_INTS-14
    ' when button pressed, display "LED-blinky"
    ' TMR1 interupts toggle LED1
    start:
          GOSUB clearLCD  
          LCDOUT $FE,$80,"  TEST 16F15345"
          LCDOUT $FE,$94,"   20250825"
          LCDOUT $FE,$D4,"        push button"   
    '               
          WHILE TASTER = 1 : WEND             ' wait for pressed taster
          PAUSE  500
    ' 
          GOSUB clearLCD 
               LCDOUT $FE,$80,"   LED-blinky"                                                         
    '      
    Main:
          PAUSE 1
          GOTO Main                                    
    '
    '*******************************************************************************
    '
    clearLCD:
          LCDOUT $FE,$01   
              RETURN
    '
    '---------------------[TMR1 - interrupt handler]--------------------------------
    ToggleLED1:
         TOGGLE LED1
    @ INT_RETURN
    Attached Files Attached Files

  4. #4
    Join Date
    May 2013
    Location
    australia
    Posts
    2,653


    Did you find this post helpful? Yes | No

    Default Re: PIC16F345 and DT_INTS-14

    to start with you have not fully defined how the main OSC is setup i would add
    OSCCON1 = $62;
    secondly you have not set a clock source for timer1, as it is it expects a clock signal on the t1clk pps pin you probably don't want that
    T1CLK = 1; ClockSource FOSC/4; 534mS
    is more like it
    thirdly the chip has auto context save for interrupts so wsave etc are not needed or even useful

    i don't have a 16f15345 chip on hand and my simulator has no model for them either so the code is untested

    but try this


    Code:
    #CONFIG
        __config _CONFIG1, _FEXTOSC_OFF & _RSTOSC_HFINT32 & _CLKOUTEN_OFF & _CSWEN_OFF & _FCMEN_OFF
        __config _CONFIG2, _MCLRE_ON & _PWRTE_ON & _LPBOREN_OFF & _BOREN_ON & _BORV_LO & _ZCD_OFF & _PPS1WAY_OFF & _STVREN_ON
        __config _CONFIG3, _WDTCPS_WDTCPS_11 & _WDTE_OFF & _WDTCWS_WDTCWS_6 & _WDTCCS_HFINTOSC
        __config _CONFIG4, _BBSIZE_BB512 & _BBEN_OFF & _SAFEN_OFF & _WRTAPP_OFF & _WRTB_OFF & _WRTC_OFF & _WRTSAF_OFF & _LVP_OFF
        __config _CONFIG5, _CP_OFF
    #ENDCONFIG
    '           
    
    
    OSCCON1 = $62;
    OSCFRQ = %101                ' 16mhz
     DEFINE OSC 16  
    ' lcd setup
     DEFINE lcd_lines 4         
     DEFINE lcd_commandus 1500    
     DEFINE lcd_dataus 44
     DEFINE LCD_DREG PORTB        
     DEFINE LCD_DBIT 4            
     DEFINE LCD_RSREG PORTC       
     DEFINE LCD_RSBIT 7           
     DEFINE LCD_EREG PORTC       
     DEFINE LCD_EBIT 6            
    '
    '-------------------- I/O ------------------------------------------------------
    ' 
      TRISC.4=1            ' input TASTER
      TRISC.5=0            ' output LED1 
      ANSELA = 0     ' ADC off all
      ANSELB = 0   ' 
      ANSELC = 0   ' 
    '
    '*******************************************************************************
    ''************************* DT_INTS-14 *****************************************
    '
    INCLUDE "DT_INTS-14_16F15345-A.bas"     ' Base Interrupt System
    INCLUDE "ReEnterPBP.bas"                ' Include if using PBP interrupts
    '
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler   TMR1_INT,  _ToggleLED1,   PBP,  yes
        endm
        INT_CREATE               ; Creates the interrupt processor
    ENDASM
    '
        
    T1CLK = 1; CS FOSC/4;   534mS
    
    
    
    
    T1CON = $31                ; Prescaler = 8, TMR1ON
    @ INT_ENABLE  TMR1_INT     ; enable Timer 1 interrupts
    '
    
    
    '*************************** PIN NAMES ***************************************** 
      TASTER     VAR portC.4       '  
      LED1       VAR portC.5   
    '
    ' test program for PIC16F15345 with DT_INTS-14
    ' when button pressed, display "LED-blinky"
    ' TMR1 interupts toggle LED1
    start:
          GOSUB clearLCD  
          LCDOUT $FE,$80,"  TEST 16F15345"
          LCDOUT $FE,$94,"   20250825"
          LCDOUT $FE,$D4,"        push button"   
    '               
          WHILE TASTER = 1 : WEND             ' wait for pressed taster
          PAUSE  500
    ' 
          GOSUB clearLCD 
               LCDOUT $FE,$80,"   LED-blinky"                                                         
    '      
    Main:
          PAUSE 1
          GOTO Main                                    
    '
    '*******************************************************************************
    '
    clearLCD:
          LCDOUT $FE,$01   
              RETURN
    '
    '---------------------[TMR1 - interrupt handler]--------------------------------
    ToggleLED1:
         TOGGLE LED1
    @ INT_RETURN
    Warning I'm not a teacher

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


    Did you find this post helpful? Yes | No

    Default Re: PIC16F345 and DT_INTS-14

    found a 16f15313 in my junk box which is from the same family tree

    changing pins to suit all works as expected
    Code:
    #CONFIG    __config _CONFIG1, _FEXTOSC_OFF & _RSTOSC_HFINT32 & _CLKOUTEN_OFF & _CSWEN_OFF & _FCMEN_OFF
        __config _CONFIG2, _MCLRE_ON & _PWRTE_ON & _LPBOREN_OFF & _BOREN_ON & _BORV_LO & _ZCD_OFF & _PPS1WAY_OFF & _STVREN_ON
        __config _CONFIG3, _WDTCPS_WDTCPS_11 & _WDTE_OFF & _WDTCWS_WDTCWS_6 & _WDTCCS_HFINTOSC
        __config _CONFIG4, _BBSIZE_BB512 & _BBEN_OFF & _SAFEN_OFF & _WRTAPP_OFF & _WRTB_OFF & _WRTC_OFF & _WRTSAF_OFF & _LVP_OFF
        __config _CONFIG5, _CP_OFF
    #ENDCONFIG
             
    
    
        OSCCON1 = $62;
        OSCFRQ = %101                ' 16mhz
        DEFINE OSC 16  
    
    
    '-------------------- I/O ------------------------------------------------------
        
        TRISa.2=0            ' output LED1 
        ANSELA = 0     ' ADC off all
    
    
    '*******************************************************************************
    ''************************* DT_INTS-14 *****************************************
    '
        INCLUDE "DT_INTS-14_16F15345-A.bas"     ' Base Interrupt System
        INCLUDE "ReEnterPBP.bas"                ' Include if using PBP interrupts
    '
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler   TMR1_INT,  _ToggleLED1,   PBP,  yes
        endm
        INT_CREATE               ; Creates the interrupt processor
    ENDASM
    '
        
        T1CLK = 1; CS FOSC/4;   534mS
        T1CON = $31   ; Prescaler = 8, TMR1ON
        
                      
    @ INT_ENABLE  TMR1_INT     ; enable Timer 1 interrupts
    '
    
    
    '*************************** PIN NAMES ***************************************** 
           
      LED1       VAR porta.2   
    
    
    ' test program for PIC16F15313 with DT_INTS-14
    
    
    ' TMR1 interupts toggle LED1
                                                             
    '      
    Main:
          PAUSE 10
    GOTO Main                                    
    '
    '*******************************************************************************
    
    
    '---------------------[TMR1 - interrupt handler]--------------------------------
    ToggleLED1:
         TOGGLE LED1       ;   534mS
    @ INT_RETURN
    Warning I'm not a teacher

Similar Threads

  1. DT_INTS for K42
    By mpgmike in forum Code Examples
    Replies: 29
    Last Post: - 7th June 2022, 16:29
  2. DT_INTS and 18F26k22
    By Mike2545 in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 9th September 2017, 16:08
  3. Dt_ints-14
    By iw2fvo in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 18th November 2013, 07:57
  4. Re: DT_Ints-18
    By Steve_88 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 4th March 2012, 18:39
  5. Problem with DT_Ints-14
    By BobSpencerr in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 1st March 2007, 05:27

Members who have read this thread : 5

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