SHIFTOUT with PIC12F675?


+ Reply to Thread
Results 1 to 12 of 12
  1. #1
    Join Date
    Feb 2022
    Posts
    51

    Default SHIFTOUT with PIC12F675?

    Hello to the Community.
    Is the Shiftout command possible for a PIC12F675?
    I ride a program using this command but my logic analyzer does not show me any pulse of Data and Clock!
    Thanks.

  2. #2
    Join Date
    Feb 2022
    Posts
    51


    Did you find this post helpful? Yes | No

    Default Re: SHIFTOUT with PIC12F675?

    Here is the test program...

    Code:
    '************************************************************************
    '   Programme: Shiftout Test PBP   (c)Roger LEGAT 07-2023
    '   RX Tester---> PIC 12F675
    ' PicBasicPro Compiler V:2.40   ---> 393 Words used
    '************************************************************************
    '*** PIC Pinouts/Specifications
    '------------------------------------
    '            PIC 12F675
    '                   __ __
    '           Vcc +|  U  |- Gnd
    '        GPIO.5 x|     |< GPIO.0
    '        GPIO.4 >|     |> GPIO.1 _DIO
    '        GPIO.3 >|     |> GPIO.2 _CLK
    '                    -----
    
    @ Device Pic12F675, intrc_osc, wdt_off, pwrt_on, mclr_off, protect_off
    
    DEFINE OSC 4    ' Pulsin/Pulsout Resolution    =10µsec    => 1ms=100
    '   (Pulse Value of 1msec x10 =1000)    [x10]
    '  Pause =1msec => 1msec=1    1sec=1000
    
    Include "modedefs.bas"   ;for shiftout command
    
    CMCON  = 7   'Comparator Off
    ANSEL  = 0   'Set Port to Digital i/o         
    ADCON0 = 0   'All ADC Off
     
    Asm
     bsf STATUS      ;Bank 1
     call 3FFh       ;Get the CAL value from 3FF addresse YOU WRITE BEFORE !
     movwf OSCCAL    ;Calibrate
     bcf STATUS, RP0 ;Bank 0
    Endasm
    
    '*** In/Out pins ..................................................
     Output 1 : _DIO var GPIO.1
     Output 2 : _CLK var GPIO.2
    
    '*** Variables/Constants
      Pack       VAR BYTE        ;Byte to send
      
     '=== MAIN PROGRAM =====================================================
    
     Pack = 255
    
    MainLoop:
     
       Shiftout _DIO,_CLK,LSBFIRST,[Pack\8] 'Send Byte
       pause 100
    
    Goto MainLoop
    
    
    ;=========== END OF PBP =================================================

  3. #3
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

    Default Re: SHIFTOUT with PIC12F675?

    Maybe it is better to define the output register more convenitional.

    Try

    TRISIO = 0

    DIO VAR GPIO.1
    CLK VAR GPIO.2

    and report back how is doing.

    Ioannis

  4. #4
    Join Date
    Feb 2022
    Posts
    51


    Did you find this post helpful? Yes | No

    Default Re: SHIFTOUT with PIC12F675?

    Hi,

    I'm trying to understand and learn:

    What might be the consequences if I set my ports as follows:

    Dio var GPIO.0
    or
    Symbol Dio = GPIO.0

    Does this make a difference to the way the program is processed?

    Thanks

  5. #5
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

    Default Re: SHIFTOUT with PIC12F675?

    Originally the problem I think was this syntax:

    '*** In/Out pins ..................................................
    Output 1 : _DIO var GPIO.1
    Output 2 : _CLK var GPIO.2

    I do not see how this can compile.

    Ioannis

  6. #6
    Join Date
    Feb 2022
    Posts
    51


    Did you find this post helpful? Yes | No

    Default Re: SHIFTOUT with PIC12F675?

    Hello,
    And yet the compiler didn't give any errors!?

    I'm going to keep your suggested syntax anyway.

    Concerning my problem with the Shiftout command, I note that a problem existed with this command for the Picaxe 08M2 (which is in fact a PIC12F1840).
    The Shiftout command was not possible for this Picaxe and it was necessary to create a small routine explained in the Picaxe manual.

    Before continuing my tests, I wondered if such a problem could also be encountered with my Pic12F675... ?

  7. #7
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

    Default Re: SHIFTOUT with PIC12F675?

    In PBP I never encountered any problems with SHIFTout or SHIFTin commands.

    I pressume you will not have too.

    Ioannis
    Last edited by Ioannis; - 25th July 2023 at 13:16.

  8. #8
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

    Default Re: SHIFTOUT with PIC12F675?

    Quote Originally Posted by zorgloub View Post
    Hello,
    And yet the compiler didn't give any errors!?
    Why would give any error?

    output 1 or output 2 are valid commands that make pin 1 or pin2 output.

    And then you define the aliases _DIO var GPIO.1 etc.

    But did not defined the TRIS register.

    Ioannis

  9. #9
    Join Date
    Feb 2022
    Posts
    51


    Did you find this post helpful? Yes | No

    Default Re: SHIFTOUT with PIC12F675?

    Quote Originally Posted by Ioannis View Post
    Why would give any error?

    But did not defined the TRIS register.

    Ioannis
    Isn't using the input or output commands for the ports used is not enough or does it work?

  10. #10
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

    Default Re: SHIFTOUT with PIC12F675?

    Yes but you defined wrong. For example _DIO var GPIO.1 is not the same as DIO var GPIO.1

    Ioannis

  11. #11
    Join Date
    Feb 2022
    Posts
    51


    Did you find this post helpful? Yes | No

    Default Re: SHIFTOUT with PIC12F675?

    Ah?
    This unnderscore character has an influence for PBP?
    I usually used this character to identify my entries or outputs on the MCU!

  12. #12
    Join Date
    Feb 2022
    Posts
    51


    Did you find this post helpful? Yes | No

    Default Re: SHIFTOUT with PIC12F675?

    To come back to my original question about the SHIFTOUT command, here's the program I'm trying to run.
    Unfortunately, I've noticed that the SHIFTOUT command doesn't produce any signals on the SDA and SCK output ports!
    Any idea why?

    Code:
    '*****************************************************************
    '*  Name     : Pulsin to TM1637.PBP                              *
    '*  Author   : RGL                                               *
    '*  Date     : 01/08/2023                                        *
    '*  Version  : 1.0                                               *
    '*  Compiler : PBPro 2.6                                        *
    '*  Notes    : 415 words used                                    *
    '*                                                               *
    '*                                                               *
    '*****************************************************************
    
    
    '*** PIC Pinouts/Specifications
    '------------------------------------
    '             PIC 12F675
    '                 __ __
    '           Vcc +|  U  |- Gnd
    '        GPio.5  |     |  GPio.0
    '  Pulse GPio.4 >|     |> GPio.1 SDA (Data)
    '        GPio.3  |     |> GPio.2 SCK (Clock)
    '                 -----
    
    @ Device Pic12F675, intrc_osc, wdt_off, pwrt_on, mclr_off, protect_off
    
    'DEFINE OSC 4    ' Pulsin/Pulsout Resolution    =10µsec    => 1ms=100   DEFAULT VALUE
    '   (Pulse Value of 1msec x10 =1000)    [x10]
    '  Pause =1msec => 1msec=1    1sec=1000
    
    Include "modedefs.bas"
    
    CMCON  = 7   'Comparator Off
    ANSEL  = 0   'Set Port to Digital i/o         
    ADCON0 = 0   'All ADC Off
    
    'OSCCAL = $4C (344C placed manually in the hex file at 3FF address)              
     
    Asm
     ;bsf STATUS      ;Bank 1
     call 3FFh       ;Get the CAL value from 3FF addresse YOU WRITE BEFORE !
     movwf OSCCAL    ;Calibrate
     ;bcf STATUS, RP0 ;Bank 0
    Endasm
    
    '*** In/Out pins ..................................................
    
     TRISIO = %010000    'GPIO.4 Input=1.  All other Output=0
    
     SDA    Var GPIO.0    'Serial Data pin
     SCK    Var GPIO.1    'Serial Clock pin
     Pulse   Var GPIO.4   'Pulsin pin
    
    
    '*** Variables/Constants
    
     CHR1 VAR BYTE             ;4 Byte to send
     CHR2 var Byte
     CHR3 var Byte
     CHR4 var Byte
    
     Value VAR WORD        ;Average Pulsin Value to display
     Measure VAR word        ;Intermediate and successives readings
    
     i  VAR BYTE        ;Working variable (20 successive measurements)
    
    
    ' TM1637 Commands
    '-------------------
     ;CMD1 CON $40       'CMD1=$40 Write command Auto-increment Mode (Default Mode)
     CMD2 CON $C0       'CMD2=$C0 Start 1st digit position(left most = 1st digit)
     CMD3 CON $8C       'CMD3=$8A is the end command that turns the display ON and sets brightness to 69%
    
      
    ; Definition of the 10 characters in the EEPROM : 0-9 +Blank
    ; (Eeprom Starting address at 0)
    
    ; EEPROM(0   1   2   3   4   5   6   7   8   9   10 ) Pos10 = Blank
    DATA @0,$3F,$06,$5B,$4F,$66,$6D,$7D,$07,$7F,$6F,$00 ; Write to Eeprom
        
    '=== INIT TM1637 =====================================================
    
    Gosub StartSeq
     SHIFTOUT SDA, SCK, 0, [CMD3]      'SHIFTOUT brightness
    Gosub AckSeq 
    gosub StopSeq
    
    '=== MAIN PROGRAM =====================================================
    MainLoop:
     Value = 0 : Measure = 0 'Initialize Value and Measure
    
      For i=1 to 20 '20 successive measurements for stabilisation of the display
        Pulsin Pulse,1,Measure
        Value = Value + Measure
      Next
      
      Value = Value /20                     ;Average PULSIN value
      Value = Value * 10                    ;Conversion to uS @4Mhz
    
    ;  Decomposition Method:
    ; ------------------------
       CHR1 = Value / 1000
         If CHR1 = 0 then
          CHR1 = 10 'Blank Char.
         Else
          CHR1 = CHR1+$80 '+Decimal point
         Endif
    
       CHR2 = Value / 100 // 10
       CHR3 = Value / 10 // 10
       CHR4 = Value // 10
    
    
    'This sequence outputs now all 4 characters to the Display
    
    Gosub StartSeq   'SHIFTOUT Mode 0 - LSB First, Clock normally low
        SHIFTOUT SDA, SCK, 0, [CMD2]    '1st Digit Adrress
     Gosub AckSeq
        
    
        SHIFTOUT SDA, SCK, 0, [CHR1]    '1st Digit value
      Gosub AckSeq
    
        SHIFTOUT SDA, SCK, 0, [CHR2]    '2e Digit value
      Gosub AckSeq
    
        SHIFTOUT SDA, SCK, 0, [CHR3]    '3e Digit value
      Gosub AckSeq
    
        SHIFTOUT SDA, SCK, 0, [CHR4]    '4e Digit value
      Gosub AckSeq
    
    Gosub StopSeq
    
    Goto MainLoop 
    
    '====================================================================
    '=============    SUBROUTINES    ====================================
    '====================================================================
    
    StartSeq:
     High SCK
     High SDA
     Low SDA
    Return
    ;--------------------------
    
    ACKSeq:
     Low SCK
     High SCK
     Low SCK
    Return
    ;--------------------------
    
    StopSeq:
     Low SCK
     Low SDA
     High SCK
     High SDA
    Return
    
    '===============  END OF PBP PROGRAMME =========================================================

Similar Threads

  1. Pic12f675
    By Andre_Pretorius in forum Serial
    Replies: 1
    Last Post: - 6th April 2009, 00:27
  2. PIC12F675 not working
    By Russ Kincaid in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 26th March 2009, 17:40
  3. SERIN with a PIC12F675
    By ewandeur in forum Serial
    Replies: 4
    Last Post: - 30th July 2007, 15:04
  4. Pic12f675
    By perides in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 11th July 2007, 20:37
  5. PIC12F675 and ADCIn
    By Peter1960 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 19th February 2005, 07:42

Members who have read this thread : 16

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