• AVR Freaks

Hot!PIC16F18326

Author
ELUMEN2018
New Member
  • Total Posts : 4
  • Reward points : 0
  • Joined: 2018/05/24 06:31:21
  • Location: 0
  • Status: offline
2019/06/17 13:05:47 (permalink)
0

PIC16F18326

Hi All,
I have problem with oscillator PIC16F18326
program for test very simple but oscillator is not work
; CONFIG1
 __CONFIG _CONFIG1, _FEXTOSC_OFF & _RSTOSC_HFINT1 & _CLKOUTEN_OFF & _CSWEN_ON & _FCMEN_ON
; CONFIG2
 __CONFIG _CONFIG2, _MCLRE_ON & _PWRTE_OFF & _WDTE_OFF & _LPBOREN_OFF & _BOREN_ON & _BORV_LOW & _PPS1WAY_ON & _STVREN_ON & _DEBUG_OFF
; CONFIG3
 __CONFIG _CONFIG3, _WRT_OFF & _LVP_ON
; CONFIG4
 __CONFIG _CONFIG4, _CP_OFF & _CPD_OFF



;**************************************************************************
; I/Os DEFINITIONS
;**************************************************************************
#define   RReset      PORTC,RC4     ; OUT Reset for other uC

      
          ORG         0x000        ; processor reset vector


          banksel     OSCCON1
          movlw        0x60          
          movwf       OSCCON1
      
      banksel     OSCSTAT1
          movlw        0x40          
          movwf       OSCSTAT1
      
      banksel     OSCCON2
          movlw        0x60          
          movwf       OSCCON2
      
    
      
      banksel     OSCCON3
          movlw        0x60          
          movwf       OSCCON3
      
    
      
      banksel     OSCEN
          movlw        0x40          
          movwf       OSCEN
      
      banksel     OSCFRQ
          movlw        0x03          
          movwf       OSCFRQ
         

      
;
;setup for port a
      banksel     PORTA
      clrf        PORTA
      banksel     LATA
      clrf        LATA
      banksel     ANSELA
      clrf        ANSELA
      banksel     WPUA
      movlw       0x04  ; for RA2 pull up resistor enabled
      movwf       WPUA
      banksel     TRISA
      movlw       0x0E  ; RA2,RA3,RA4 inputs, other outputs
      movwf       TRISA
      
;setup for port c
      banksel     PORTC
      clrf        PORTC
      banksel     LATC
      clrf        LATC
      banksel     ANSELC
      clrf        ANSELC
      banksel     TRISC
      movlw       0x04  ; RC2 input, other outputs
      movwf       TRISC
ssss:
          bsf         RReset
  goto ssss; this example
      end
my be oscillator not programmed correctly.....
thanks for all
#1

7 Replies Related Threads

    mpgmike
    Super Member
    • Total Posts : 179
    • Reward points : 0
    • Joined: 2014/01/23 17:27:06
    • Location: NJ
    • Status: online
    Re: PIC16F18326 2019/06/18 16:20:27 (permalink)
    +2 (2)
    1. Why are you writing to OSCSTAT1?
    2. How do you know you have no oscillator?  You have CLKOUTEN disabled.
     
    There are a few folks here that have programmed in ASM, but most use XC8_16_32.  How do you know you have no oscillator is the golden question that can start meaningful dialog.

    I don't need the world to know my name, but I want to live a life so all my great-grandchildren proudly remember me.
    #2
    ELUMEN2018
    New Member
    • Total Posts : 4
    • Reward points : 0
    • Joined: 2018/05/24 06:31:21
    • Location: 0
    • Status: offline
    Re: PIC16F18326 2019/06/19 11:15:25 (permalink)
    0
    But in data sheet this chip for internal oscillator I need write data to these registers
    and if I add delay to programm
    for example
    ssss:
    bsf RReset
    call delay2sec
    bcf RReset
    call delay2sec
    goto ssss
    ,
    ..
     delay2sec:
           movlw	0x11
    movwf d1
    movlw 0x5D
    movwf d2
    movlw 0x05
    movwf d3
    Delay_0:
    decfsz d1, f
    goto $+2
    decfsz d2, f
    goto $+2
    decfsz d3, f
    goto Delay_0

    ;4 cycles
    goto $+1
    goto $+1
    return

    nothing not work led is not flashing (RReset)
    this all you can help me for this
    thanks
    #3
    ric
    Super Member
    • Total Posts : 22768
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: PIC16F18326 2019/06/19 13:29:27 (permalink)
    +2 (2)
    You do not seem to be reading the responses.
    Question number 1 was "how do you know you have no oscillator?"
    You could easily check by changing the _CLKOUTEN_OFF setting to _CLKOUTEN_ON so the oscillator would be output on a pin for easy checking.
     
    Plainly you have SOME problem, and you assume it is because your oscillator is not running.
    To be able to help, we need to know what you actually measured and what you observed to come to this conclusion.
    We don't have your test board, so you have to be our eyes and ears.
     

    and if I add delay to programm
    for example
    ...

    and what? You show some code, but say nothing about why, or what happened when you tried it.

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #4
    ELUMEN2018
    New Member
    • Total Posts : 4
    • Reward points : 0
    • Joined: 2018/05/24 06:31:21
    • Location: 0
    • Status: offline
    Re: PIC16F18326 2019/06/21 11:52:28 (permalink)
    0
    Hi All
    for my problem its resolved
    I checked in CLKOUT for oscilator its work
    and add Macro for change BANK
    this  code
    list        p=16f18326   ; list directive to define processor
             #include  <P16F18326.inc>          ; processor specific definitions
            


     __CONFIG _CONFIG1, _FEXTOSC_OFF & _RSTOSC_HFINT1 & _CLKOUTEN_ON & _CSWEN_ON & _FCMEN_ON


     __CONFIG _CONFIG2, _MCLRE_ON & _PWRTE_OFF & _WDTE_OFF & _LPBOREN_OFF & _BOREN_ON & _BORV_LOW & _PPS1WAY_ON & _STVREN_ON & _DEBUG_OFF


     __CONFIG _CONFIG3, _WRT_OFF & _LVP_ON


     __CONFIG _CONFIG4, _CP_OFF & _CPD_OFF




    #define   RReset      PORTC,RC4     ; OUT Reset for other uC

            SELBANK MACRO   #BANK_NO
            MOVLW   #BANK_NO
        MOVWF   BSR        ;The active bank is selected by writing the >
            ENDM               ;bank number into the Bank Select Register (BSR)
          
              ORG         0x000        ; processor reset vector


              banksel     OSCCON1
              movlw        0x60          
              movwf       OSCCON1
          
         
          banksel     PORTC
          clrf        PORTC
          banksel     LATC
          clrf        LATC
          banksel     ANSELC
          clrf        ANSELC
          banksel     TRISC
          movlw       B'00111000'
          movwf       TRISC
          
              SELBANK 0
    ssss:
              bsf         RReset
          
              goto ssss
        

          end
    #5
    ric
    Super Member
    • Total Posts : 22768
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: PIC16F18326 2019/06/21 15:47:01 (permalink)
    +3 (3)
    So, the problem had nothing to do with the oscillator, and was just a bug in your code, neglecting to select the bank containing PORTC after you had written to TRISC.
     
    Why did you need to define a new macro?
    You are already using the built in BANKSEL macro, which takes the name of a register in the desired bank as a parameter.
    Instead of "SELBANK 0" you could have just put "BANKSEL PORTC".
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #6
    pcbbc
    Super Member
    • Total Posts : 1108
    • Reward points : 0
    • Joined: 2014/03/27 07:04:41
    • Location: 0
    • Status: offline
    Re: PIC16F18326 2019/06/22 01:24:35 (permalink)
    +2 (2)
    Additionally you have the MOVLB instruction, which avoids the need to move the literal through the W register and uses only a single machine instruction. Copying data between registers in different banks would be incredibly tedious without it.

    But I still have no idea why the OP decided to code their own macro!
    #7
    ELUMEN2018
    New Member
    • Total Posts : 4
    • Reward points : 0
    • Joined: 2018/05/24 06:31:21
    • Location: 0
    • Status: offline
    Re: PIC16F18326 2019/06/26 07:33:05 (permalink)
    0
    thanks for All users
    #8
    Jump to:
    © 2019 APG vNext Commercial Version 4.5