Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Is there a PIC 16F627A with a 20MHz internal oscillator?

Status
Not open for further replies.
Hi, I am developing a project for a guy who doesn't like too much soldering, so I have established a schematic without an external crystal. I have seen ads from parts sellers that there is a 20MHz version of the PIC 16F627A, and have already told him to go ahead and aquire it...

Now, I have read on the MicroChip site that the 16F627A has a 4MHz internal oscillator. I do not see the 20MHz version. I have already developed the program for a version of a PIC which, it seems, has the same internal crystal as the 4MHz version.

Please, is there a PIC16F627A 20MHz version with an internal oscillator which is 20MHz, or does it only support a 20MHz crystal, and if so, how do I attach it and set it up?
 
No, the internal oscillator on the 16F627A is 8MHz max. It supports external clocks upto 20MHz and the connection diagram is in the datasheet.
20MHz xtal + two 18pf caps on the OSC inputs.
 
Well, thank you :)
Very much :)
I will then recode to use 4MHz, as I did timing in code.
HS setup bit for the 4MHz internal?

The microchip site says there is only a 4MHz version... I coded an entire program wrong :)
 
Last edited:
No use the intosc config settings and I stand corrected it's only a 4MHz or 48kHz internal osc.
This should be your oscillator config setting
Code:
[FONT=Courier New][SIZE=2] __CONFIG _INTRC_OSC_NOCLKOUT[/SIZE][/FONT]
More code examples here
LED chaser
 
Last edited:
How wrong...?

I coded an entire program wrong :)

I wonder how wrong it could be!? Your timing, is it based on inline code or just subroutines called here and there?

How many lines need to be changed to fit the new clcok?

Dare to say that it should be not too hard to adapt to the new clock frequency.
 
Last edited:
Well, I just saw the wave diagram, and there is a 25.5 microseconds period required as 50% duty cycle, so... I just hope it will work when I round it off :) I based the timing on both, so it could be anything from hard to futile.
 
What is it that requires a 25.5 uS period?

If you provide more info people can help you better instead of just being made to take wild shots in the dark...
 
A unit

It is some kind of a unit to which I send a clock signal with 51 microseconds delay then read a bit 5 microseconds after sending the signal. The first bit has its own pin. However, the guy says that, although I tested it in the simulator and it generates the signal, it does not work!

So, PLEASE HELP!

I am sending the signal pulses over rb2 and rb3, is that the problem?
I am sending them by putting the 00000100 or 00001000 in wreg and movwf PORTB.
I am also using the rb0 and rb1 for input, rb0 for edge interrupt.
I just don't know what is wrong...

The portb is polled for a low signal on the rb1 which takes us to start.
I am creating the timing by counting off instruction times (1 microsecond per instruction)

Maybe I should disable the pullups on portb? Maybe that is why it doesn't send signals?

Please see my init code, perhaps I made an error there?

In the simulator I see rb2 and rb3 pins going on and off, yet the guy who tests it gets nothing...

Here is the code for the start sequence which should generate the pulses:
Code:
;=============================================================================

; *--------*     *----------------*      *---------*
; |       0|-----|ra0          ra6|------|data     |
; |        |-----|ra1             |      |         |
; |   PC   |-----|ra2 PIC 16F627A |      |         |
; |        |-----|ra3             |      |         |
; |        |-----|ra4             |      |         |
; |        |-----|    RB5!        |      |         |
; |        |-----|    RB6         |      |         |
; |       7|-----|ra7             |      |         |
; |        |     |                | 5V   |         |
; |   Start|-----|rb1          rb2|--*10V|         |
; |    Read|-----|rb0             |  |   |         |
; |        |     |             rb3|------|clock    |
; *--------*     *----------------*      *---------*

        list p=16f627A        
        #include <p16f627A.inc>    
__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _INTOSC_OSC_NOCLKOUT & _LVP_OFF 

        errorlevel -302        
    #define bank0 bcf 3,5
    #define bank1 bsf 3,5
    #define startbit1 movwf PORTB ; bit 1 clock signal start
    #define stopbit1 movwf PORTB ; bit 1 clock signal stop
    #define startbit2192 movwf PORTB
    #define stopbit2192 movwf PORTB
    #define readbit movf PORTA,0

;----------------------------------------------------------------------------
;Constants

;----------------------------------------------------------------------------
;Variables
		CBLOCK	0x30
		WREG_TEMP		;storage for WREG during interrupt
		STATUS_TEMP		;storage for STATUS during interrupt
		PCLATH_TEMP		;storage for PCLATH during interrupt
		FSR_TEMP		;storage for FSR during interrupt
                CORRECTION ; counter for the correction of frequency during start
                BITCOUNT   ; number of bits remaining to be read to fill up a byte
                BYTECOUNT  ; number of bytes read or sent
                READSTART  ; indicator of state of program, when in start state true
                BUFFER     ; this is where we rotate the bits we read into
                COUNTER    ; counter for delay of 5 microseconds
                SIGNAL     ; we copy PORTB to this register when we want to poll it
                BYTE0
                BYTE1
                BYTE2
                BYTE3
                BYTE4
                BYTE5
                BYTE6
                BYTE7
                BYTE8
                BYTE9
                BYTE10
                BYTE11
                BYTE12
                BYTE13
                BYTE14
                BYTE15
                BYTE16
                BYTE17
                BYTE18
                BYTE19
                BYTE20
                BYTE21
                BYTE22
                BYTE23
                
        ENDC
;----------------------------------------------------------------------------
;This code executes when a reset occurs.
ResetCode:    clrf    PCLATH        
        goto    Main   
        ORG    0x0004        
        goto    InterruptCode

     
            
          
Main:    
    bank0
    clrf PORTA
    movlw 0x07 ;Turn comparators off and
    movwf CMCON ;enable pins for I/O
    clrf T1CON
    clrf PORTB
    bank1
    movlw b'01000000'
    movwf TRISA ; configure port a for output and pin 6 for input
    movlw b'00000011'
    movwf TRISB ; configure port b pins 0 and 1 for input
    clrf OPTION_REG ; interrupt on falling edge
    bank0
    clrf READSTART
    clrf BUFFER
    clrf BYTECOUNT
    clrf PIR1
    clrf PIE1
    clrf SIGNAL
    movlw b'10010000'
    movwf INTCON ; enable interrupt rb0
    clrf STATUS
Signals:
    movf PORTB,0
    movwf SIGNAL
    btfss SIGNAL,1
    goto start
    goto Signals

start:
    clrf INTCON
    clrf PORTA ; data bus = 00000000
    clrf PORTB
    clrf CORRECTION
    movlw 8
    movwf BITCOUNT
    movlw .24
    movwf BYTECOUNT
bit1program:
    movlw b'00000100'
    startbit1 ; puts ra2 to high
    nop
    nop
    nop
    nop
    bcf STATUS,0
    readbit ; 5.25 microseconds after clock going to high
    movwf SIGNAL
    btfsc SIGNAL,6
    bsf STATUS,0
 
Last edited:
Perhaps I need to set up the mplab 8.40 to compile into hex format other than INTHX32, the default one?

I will try that.

Should I have the MCLR and BODEN configuration bits enabled or disabled?
 
Last edited:
Looks like you are making one of your own protocol.
To make the design compact I use MCLR = OFF.Brownout is upto you.For DC its ok turning off.But when dealing with AC mains I surely use BODEN = ON.

I also noticed in some chips internal MCLR is giving problems too.It wont reset the chip properly.
 
Last edited:
Thanks for your reply, it must be up to configuration of his pic programmer since I tested and it works properly, right?

I only do not know if I should disable weak pullups to have the output working on rb2 and rb3?

Everything else I have checked.
 
Thanks! Now I need to setup a reset button, I have been reading about it and it seems that all I need to do is add a switch from A5 pin connected to Vss with a 50 - 100 K resistor?
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top