Pic16f18877 oread


Yesterday 23:03
Forum: Proton Plus Compiler v3
Starter: gdesantis
Views: 0
Replies: 3
Yesterday 20:28
Forum: PICKit Plus
Starter: evan
Views: 0
Replies: 7
+ Reply to Thread
Page 1 of 3 123 LastLast
Results 1 to 10 of 21

Thread: Pic16f18877 oread56 days old

  1. #1
    Junior Member evoortman's Avatar
    Join Date
    Nov 2004
    Posts
    48
    Thumbs Up
    Received: 0
    Given: 0
    Total Downloaded
    151.53 MB

    0 Not allowed!

    Default Pic16f18877 oread

    Hi,

    On a PIC16F18877 the OREAD command doesn't seem to work.
    The code is working on a PIC16F1939. Both controllers use 32MHz int osc.
    If i compare te signals with a logic analyser then the signal from the PIC16F18877 is twice as slow.
    There is also a led toggled to see if both controllers work at te same speed.
    Does the OREAD command not work properly with the PIC16F18877?


    Device = 16F18877
    Config1 FEXTOSC_OFF, RSTOSC_HFINT32, CLKOUTEN_ON, CSWEN_OFF, FCMEN_OFF
    Config2 MCLRE_OFF, PWRTE_ON, LPBOREN_OFF, BOREN_OFF, BORV_HI, ZCD_OFF, ZCDDIS_OFF, PPS1WAY_OFF, STVREN_OFF, DEBUG_OFF
    Config3 WDTCPS_WDTCPS_8, WDTE_OFF, WDTCWS_WDTCWS_7, WDTCCS_SC
    Config4 WRT_ON, SCANE_not_available, LVP_OF
    Config5 CP_OFF, CPD_OFF

    Declare Xtal = 32
    Declare All_Digital = TRUE
    ANSELC = 0

    'Device = 16F1939
    'Config1 FOSC_INTOSC, WDTE_SWDTEN, PWRTE_ON, MCLRE_OFF, CP_OFF, CPD_OFF, BOREN_OFF, CLKOUTEN_ON, IESO_OFF, FCMEN_OFF
    'Config2 WRT_HALF, VCAPEN_OFF, PLLEN_ON, STVREN_ON, BORV_19, LVP_OFF

    'Declare Xtal = 32
    'Declare All_Digital = TRUE
    'OSCCON = 110000 ' 32Mhz int osc

    LATA = 0
    LATB = 0
    LATC = 0
    LATD = 0
    LATE = 0

    Symbol ONE_WIRE = PORTC.6
    Symbol LED_RED = PORTC.1
    Symbol LED_YELLOW = PORTC.2

    Output LED_RED
    Output LED_YELLOW

    Dim ONE_WIRE_DATA[10] As Byte

    START:
    DelayMS 1000
    Toggle LED_YELLOW

    OWrite ONE_WIRE, 1, NO_PRESENCE,[$33] ' Send ROM command if no ID then jump to NO_PRESENCE_1
    ORead ONE_WIRE, 2, [Str ONE_WIRE_DATA \ 8] ' Read ADDRESS from silicon serial chip

    NO_PRESENCE:
    GoTo START

  2. #2
    Prolific Poster towlerg's Avatar
    Join Date
    Mar 2012
    Posts
    1,853
    Thumbs Up
    Received: 163
    Given: 162
    Total Downloaded
    3.24 GB

    0 Not allowed!

    Default Re: Pic16f18877 oread

    Are you sure that the speed you have declared (32 Mhz) is what the actual device is doing? There are several easy ways to test. Some devices have the option of repeating the clock to a physical pin alternatly write a blinky and count.
    George

  3. #3
    Junior Member evoortman's Avatar
    Join Date
    Nov 2004
    Posts
    48
    Thumbs Up
    Received: 0
    Given: 0
    Total Downloaded
    151.53 MB

    0 Not allowed!

    Default Re: Pic16f18877 oread

    There is already a blinking led in the code.
    The led is blinking at the same speed with both controllers.
    The output on the clockout pin is also 8MHz (clk/4) on both cotrollers.
    For now it seems that the OREAD command does not work properly with this relatively recent added controller.
    Does somebody else have other sugestions?

  4. #4
    Prolific Poster towlerg's Avatar
    Join Date
    Mar 2012
    Posts
    1,853
    Thumbs Up
    Received: 163
    Given: 162
    Total Downloaded
    3.24 GB

    0 Not allowed!

    Default Re: Pic16f18877 oread

    Ok, sorry I should have read more carefully. Is it literally twice as slow?

    I don't suppose it's relevant but I see you can change the divider of the external clock on this device. With CLKRDIV = 0 (it's default) external clock is same as fosc.

    If push comes to shove here

    BTW Your avatar is a hoot, like the subtle wink.
    Last edited by towlerg; 19th October 2018 at 14:04.
    George

  5. #5
    Prolific Poster towlerg's Avatar
    Join Date
    Mar 2012
    Posts
    1,853
    Thumbs Up
    Received: 163
    Given: 162
    Total Downloaded
    3.24 GB

    0 Not allowed!

    Default Re: Pic16f18877 oread

    I can't update my previous post but it occurs to me that the one wire interface does not use any potentially updated peripherals on the 16F18877, it is bit banged so it's hard to see that there is a compiler problem. I assume the one wire code just sets i/o direction and value, I know that Les could elaborate on that.
    George

  6. #6
    Prolific Poster See_Mos's Avatar
    Join Date
    Feb 2004
    Posts
    1,212
    Thumbs Up
    Received: 18
    Given: 0
    Total Downloaded
    614.99 MB

    0 Not allowed!

    Default Re: Pic16f18877 oread

    Yes George, the one-wire code is completely software driven.

    I compiled the code for both devices and had a look at the assembler and from the start of the BASIC to the end they both appear to be the same and the timings are just short of those shown in the data sheet, add the rest of the code and the timings are correct.
    My RAM is failing

  7. #7
    Junior Member evoortman's Avatar
    Join Date
    Nov 2004
    Posts
    48
    Thumbs Up
    Received: 0
    Given: 0
    Total Downloaded
    151.53 MB

    0 Not allowed!

    Default Re: Pic16f18877 oread

    I've made some screenshots of my logic analyzer: https://imgur.com/a/MJohgAo

    The first picture is from the 16F1939 and shows the expected communication when there is no device connected. A reset puls of around 480uS with no response and as such there will be no more communication.
    The second picture is from the 16F18877 and has a reset puls that is twice as long. This is longer than the 1-wire specifications allows. Also, it somehow thinks there is a device connected and continues the communication.

    The third and fourth picture shows the communication if there is a DS2413 attached. And as shown in the screenshots, the delay between the data pulses of the 16F18877 are twice as long as the pulses of the 16F1939.

    As a fifth picture I've included some differences in the assembly library code produced. The 16F18877 assembly contains double the amount of __DELAY_US_ calls, which could explain the longer resets and pulses even though the variables used in these delays don't differ that much (movlw 60 vs movlw 56 + movlw 9).

  8. #8
    Prolific Poster towlerg's Avatar
    Join Date
    Mar 2012
    Posts
    1,853
    Thumbs Up
    Received: 163
    Given: 162
    Total Downloaded
    3.24 GB

    0 Not allowed!

    Default Re: Pic16f18877 oread

    Your plots a too small to read values but unless somebody comes up with an alternate explaination, if the pulses are exactly twice length on one device compared with other, doesn't somebodies sythe suggest the most obvious solution, in this case the device is running twice as fast as the xtal declare.
    George

  9. #9
    Prolific Poster See_Mos's Avatar
    Join Date
    Feb 2004
    Posts
    1,212
    Thumbs Up
    Received: 18
    Given: 0
    Total Downloaded
    614.99 MB

    0 Not allowed!

    Default Re: Pic16f18877 oread

    Hi George, I found it impossible to read as well but if you save it to your desktop you can open it with Windows photo viewer. It's clearer and you can zoom in as well.

    I must admit that I did not look at the ORead and OWrite routines so I missed that bit and while I can follow the 16F1939 ASM I cannot follow the 16F18877 as it uses OpCodes that I do not know, yet!

    Post #3 says the LED is flashing at the correct rate on both devices so it has to be in the one-wire routines.
    My RAM is failing

  10. #10
    Junior Member kuhrig's Avatar
    Join Date
    Aug 2005
    Posts
    71
    Thumbs Up
    Received: 2
    Given: 0
    Total Downloaded
    3.15 GB

    0 Not allowed!

    Default Re: Pic16f18877 oread

  11. I am upgrading from PIC 16F1939 to PIC 16F18877 and found that I have to declare the xtal 2x higher than the internal oscillator to get the correct timing. My xtal = 16 where is my OSCFRQ is set at 8 MHz. Not sure if this will help you to get a shorter pulse or I made another mistake by setting the frequency.

Thread Information

Users Browsing this Thread

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

     

Similar Threads

  1. PIC16F18877 - no PWM output
    By kuhrig in forum Proton Plus Compiler v3
    Replies: 6
    Last Post: 26th September 2018, 18:09
  2. EData and ERead problems in a PIC16F18877
    By bradysmall in forum Proton Plus Compiler v3
    Replies: 7
    Last Post: 17th August 2018, 18:57
  3. Oread on open drain pin
    By rcurl in forum Proton Plus Compiler v3
    Replies: 2
    Last Post: 25th February 2017, 04:37
  4. Pic16f18877
    By teo in forum Proton Plus Compiler v3
    Replies: 2
    Last Post: 4th December 2016, 16:47
  5. 1-Wire oRead returns Zeros
    By mjturner in forum Proton Plus Compiler v3
    Replies: 5
    Last Post: 10th January 2016, 18:04

Members who have read this thread : 42

Actions :  (Set Date)

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