[SOLVED !] Same code different pic


Closed Thread
Results 1 to 6 of 6

Thread: Same code different pic878 days old

  1. #1
    vissie
    Guest vissie's Avatar

    0 Not allowed!

    Default Same code different pic

    hello,

    i have write a code for the 16f628a on the internal clock.
    it receive a external clock puls on on the portb.0 white a interupt and send a bit out on a pin. this works fine no problems at al.

    this pic do not have enough ports so i choise a other one. that is the 16f723a
    i set the internal clock to 16mhz and now it same that de code is not fast enough.
    the output is not stabel.
    i now use the portb change interupt in place of the external edge detect.

    this is mine code
    Code:
    DEVICE = 16F723A
    
    CONFIG1 FOSC_INTOSCIO, WDTE_OFF, PWRTE_ON, MCLRE_OFF, CP_OFF, BOREN_OFF, BORV_19, PLLEN_ON, DEBUG_OFF
    CONFIG2 VCAPEN_DIS
    
    
    XTAL = 16
    ALL_DIGITAL True
    
    
    ON_INTERRUPT event
    
    
    
    
    SYMBOL gie    = INTCON.7
    SYMBOL rbie   = INTCON.3
    SYMBOL rbif   = INTCON.0
    
    
    SYMBOL iocb1  = IOCB.1
    SYMBOL iocb0  = IOCB.0
    SYMBOL iocb3  = IOCB.3
    
    
    WPUB.1 = 1
    
    
            ;76543210
    PORTA = %00000000
    PORTB = %00000000
    PORTC = %00000000
    TRISA = %11111111
    TRISB = %11111011
    TRISC = %11111111
    
    
    SYMBOL s88_data_uit = PORTB.2
    SYMBOL s88_data_in  = PORTC.7
    SYMBOL s88_clock    = PORTB.1
    SYMBOL s88_load     = PORTB.0
    SYMBOL s88_reset    = PORTB.3
    SYMBOL i1           = PORTA.7
    SYMBOL i2           = PORTA.6
    SYMBOL i3           = PORTC.0
    SYMBOL i4           = PORTC.1
    SYMBOL i5           = PORTC.2
    SYMBOL i6           = PORTC.4
    SYMBOL i7           = PORTC.5
    SYMBOL i8           = PORTC.6
    SYMBOL i9           = PORTA.0
    SYMBOL i10          = PORTA.1
    SYMBOL i11          = PORTA.2
    SYMBOL i12          = PORTA.3
    SYMBOL i13          = PORTA.4
    SYMBOL i14          = PORTA.5
    SYMBOL i15          = PORTB.4
    SYMBOL i16          = PORTB.5
    
    
    DIM s88_output      AS WORD
    
    
    DIM input_a         AS BYTE
    DIM input_b         AS BYTE
    
    
    DIM load_set        AS BIT
    
    
    CLEAR
    DELAYMS 250
    
    
    load_set = 0
    
    
    iocb1 = 1
    rbif  = 0
    rbie  = 1
    gie   = 1
    
    
    GOTO main
    
    
    event:
      CONTEXT SAVE
        gie = 0
       
        
        IF s88_clock = 1 THEN
          s88_data_uit = s88_output.0
          s88_output = s88_output >> 1
          WHILE s88_clock = 1 : WEND
        ENDIF
        rbif = 0
        gie = 1
      CONTEXT RESTORE
    
    
    main:
    WHILE 1 = 1
      IF s88_load = 1 AND load_set = 0 THEN
        s88_output = %1010101010101010
        load_set = 1
      ELSEIF s88_load = 0 AND load_set = 1 THEN
        load_set = 0
      ENDIF
      
    WEND
    
    
    END
    this code works stable on the slower 16f628a and not stable on the 16f723a it looks like it falls behind. when i look at the external clock signal on the scoop it looks like it's jamd. but only when there is code between the while wend loop in the main loop.

    do i something wrong within the config code that cause it to slow down? or is it somthingels?

    vincent

  2. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  3. #2
    Member Dompie's Avatar
    Join Date
    Apr 2012
    Posts
    161
    Thumbs Up
    Received: 19
    Given: 15
    Total Downloaded
    5.19 GB

    0 Not allowed!

    Default Re: Same code different pic

    See datasheet chapter 7.4 Oscilator Control. Default is 8Mhz or 250Khz, so you have to set the IRCF (Internal Oscillator Frequency Select bits) to 11 in your code. Only declare xtal=16 isn't enough, I believe.Johan (Chrome steals my CR's???)

  4. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  5. #3
    Senior Member Stephen Moss's Avatar
    Join Date
    Jan 2006
    Posts
    559
    Thumbs Up
    Received: 35
    Given: 7
    Total Downloaded
    3.87 GB

    0 Not allowed!

    Default Re: Same code different pic

    The 16F628A has one fixed internal oscillator frequency of 4MHz. It looks like you have made the dangerous assumption that the 16F723a is the same, when in fact it has eight possible frequencies depending on the combination PLL and IRCF bits in the OSCON register (see datasheet page 73).

    As you have enabled the PLL in your fuse configuration I suspect that the lack of OSCON setting has resulted a different output frequency from the internal clock. Adding the following either just before or just after XTAL = 16 should get you an internal 16MHz clock...
    OSCON = $30

  6. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  7. #4
    vissie
    Guest vissie's Avatar

    0 Not allowed!

    Default Re: Same code different pic

    to bad, no divrens.

  8. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  9. #5
    Prolific Poster See_Mos's Avatar
    Join Date
    Feb 2004
    Posts
    1,332
    Thumbs Up
    Received: 20
    Given: 0
    Total Downloaded
    1.01 GB

    0 Not allowed!

    Default Re: Same code different pic

    Go back to the beginning.
    Try this very simple code to show the oscillator is correct.
    Change the LED port to any port pin with an LED connected.

    Code:
    ;-------------------------------------------------------------------------------
    ;**** Added by Fuse Configurator ****
    ; Use the Fuse Configurator plug-in to change these settings
    
    Device = 16F723
    Xtal 16
    
    Config1 FOSC_INTOSCIO, WDTE_OFF, PWRTE_OFF, MCLRE_ON, CP_OFF, BOREN_ON, BORV_19, PLLEN_ON, DEBUG_OFF
    Config2 VCAPEN_DIS
    
    ;**** End of Fuse Configurator Settings ****
    ;-------------------------------------------------------------------------------
    OSCCON = $30
    
    Symbol LED = PORTB.0
    
    Do
    Toggle LED
    DelayMS 1000
    Loop
    My RAM is failing

  10. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  11. #6
    Fanatical Contributor top204's Avatar
    Join Date
    Feb 2002
    Posts
    3,710
    Thumbs Up
    Received: 364
    Given: 173
    Total Downloaded
    2.08 GB

    0 Not allowed!

    Default Re: Same code different pic

    Stephen is absolutely correct. Try a simple piece of code that toggles an LED, and see if the LED flashes at the correct rate, or do an Rsout or Hrsout command and see if the Baud matches on a terminal.

    Remember, the 16F628A is many, many years old now, and devices have evolved, and even the 16F723 is an old device.

    Later devices have internal clock manipulation that allows the user to set it up to several frequencies.

    As is always said here on the forum. "Before using a device, always read, and understand, the datasheet" Without information concerning the device, failures are regular, with any language!

  12. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. pic register in code explorer
    By Baspro in forum Absolute Beginners Section
    Replies: 6
    Last Post: 7th June 2013, 18:04
  2. Replies: 3
    Last Post: 28th April 2010, 11:16
  3. PIC to digital volume control code
    By radiotek in forum Proton Plus Compiler v3
    Replies: 24
    Last Post: 7th February 2009, 20:07
  4. touch screen to PIC ,code and shematic
    By digitalis in forum Proton Plus Compiler v3
    Replies: 15
    Last Post: 29th April 2008, 12:46
  5. Reseting a PIC from within the code
    By jonnykyoto in forum Proton Plus Compiler v3
    Replies: 4
    Last Post: 23rd November 2006, 10:50

Tags for this Thread

Posting Permissions

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