PIC24EP SPI problem


+ Reply to Thread
Results 1 to 9 of 9

Thread: PIC24EP SPI problem1227 days old

  1. #1
    tadd
    Guest tadd's Avatar

    1 Not allowed!

    Default PIC24EP SPI problem

    my code , why spi is not working ? no clock , only i see data but 8bit

    Code:
    SPI1CON1.10 = 1     '16bit data
    SPI1CON1.5 = 1      'master mode
    SPI1CON1.8 = 1      'Serial output data changes on transition from active clock state to Idle clock state
    SPI1CON2.15 = 1     'Framed SPIx support is enabled
    SPI1CON2.13 = 0     'Frame Sync pulse is active-low
    
    
    '00010010 = 18 SPI1 RpI18 porta.2 dataout
    RPINR20.0 = 0
    RPINR20.1 = 1
    RPINR20.2 = 0
    RPINR20.3 = 0
    RPINR20.4 = 1
    RPINR20.5 = 0
    RPINR20.6 = 0
    
    
    '01001010 = 74 SPI1 RpI74 PORTD10 clock
    RPINR20.8 = 0
    RPINR20.9 = 1
    RPINR20.10 = 0
    RPINR20.11 = 1
    RPINR20.12 = 0
    RPINR20.13 = 0
    RPINR20.14 = 1
    
    
    '00110010 = 50 SPI1 RpI50 PORTC2 SYNC/SS1
    RPINR21.0 = 0
    RPINR21.1 = 1
    RPINR21.2 = 0
    RPINR21.3 = 0
    RPINR21.4 = 1
    RPINR21.5 = 1
    RPINR21.6 = 0
    
    
    SPI1STAT.15 = 1     'SPI1 enabled
    
    
    
    
    Set PORTC.2 'SYNC
    Symbol DTA = PORTA.2
    Symbol CLK = PORTD.10
    Symbol RDY = PORTD.11
    
    MAIN:
    
    
    
    
    dac_data = %0000011111001111
    
    
    Set RDY
    Low PORTC.2
        DelayUS 1
        SHOut DTA, CLK, MsbFirst_L, [%0000011111001111]
        DelayUS 1
    Set PORTC.2
    Low RDY
        
    DelayMS 10
    
    
    GoTo MAIN

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.

  • #2
    Prolific Poster John Drew's Avatar
    Join Date
    Feb 2002
    Posts
    2,779
    Thumbs Up
    Received: 83
    Given: 34
    Total Downloaded
    4.30 GB

    0 Not allowed!

    Default Re: PIC24EP SPI problem

    You have no device defined and xtal frequency etc.

  • 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
    Fanatical Contributor top204's Avatar
    Join Date
    Feb 2002
    Posts
    3,404
    Thumbs Up
    Received: 290
    Given: 141
    Total Downloaded
    1.68 GB

    0 Not allowed!

    Default Re: PIC24EP SPI problem

    Also remember that the Shout command will transmit 8-bits, unless otherwise told to do larger or smaller amounts of bits. See page 377 of the Proton24 compiler manual.

    In order to transmit the 16-bits, use:

    SHOut DTA, CLK, MsbFirst_L, [%0000011111001111\16]

  • 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.

  • #4
    tadd
    Guest tadd's Avatar

    0 Not allowed!

    Default Re: PIC24EP SPI problem

    i changed 16bit and i see 16bit data pin but i can't see clock, Les ?
    Last edited by tadd; 11th July 2016 at 09: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.

  • #5
    tadd
    Guest tadd's Avatar

    0 Not allowed!

    Default Re: PIC24EP SPI problem

    Code:
    Device = 24EP256GU810
    Declare Xtal = 140
    
    
    PLL_Setup(76, 2, 2, $0300)
    Config FGS = GSS_OFF, GSSK_OFF, GWRP_OFF
    Config FOSCSEL = FNOSC_FRCPLL, IESO_ON
    Config FOSC = FCKSM_CSDCMD, IOL1WAY_ON, OSCIOFNC_OFF, POSCMD_NONE
    Config FWDT = FWDTEN_OFF, PLLKEN_ON, WDTPOST_PS32768, WDTPRE_PR128, WINDIS_OFF
    Config FPOR = ALTI2C1_OFF, ALTI2C2_OFF, BOREN_ON, FPWRT_PWR128
    Config FICD = ICS_PGD1, JTAGEN_ON, RSTPRI_PF
    Config FAS = APL_OFF, APLK_OFF, AWRP_OFF
    
    
    ;**** End of Fuse Configurator Settings ****
    ;-------------------------------------------------------------------------------
    
    
    TRISA = 0000100000       '0-7,9-10-14-15
    TRISB = 11000000000100   '16bit
    TRISC = 000011           '1-2-3-4-12-13-14-15
    TRISD = 00000000000000   '16bit
    TRISE = 01101100         '0-10 bit
    TRISF = 0000000          '0-5,8-12-13
    TRISG = 0010             '2-3-6-7-8-9
    
    SPI1CON1.10 = 1 '16bit dataSPI1CON1.5 = 1 'master mode SPI1CON1.8 = 1 'Serial output data changes on transition from active clock state to Idle clock state SPI1CON1.12 = 0 SPI1CON2.15 = 1 'Framed SPIx support is enabled SPI1CON2.13 = 0 'Frame Sync pulse is active-low SPI1CON2.0 = 1 'Enhanced Buffer Enable bit 2x8bit '00010010 = 18 SPI1 RpI18 porta.2 dataout RPINR20.0 = 0 RPINR20.1 = 1 RPINR20.2 = 0 RPINR20.3 = 0 RPINR20.4 = 1 RPINR20.5 = 0 RPINR20.6 = 0 '01101000 F8 104 '01001010 = 74 SPI1 RpI74 PORTD10 clock RPINR20.8 = 0 RPINR20.9 = 0 RPINR20.10 = 0 RPINR20.11 = 1 RPINR20.12 = 0 RPINR20.13 = 1 RPINR20.14 = 1 '00110010 = 50 SPI1 RpI50 PORTC2 SYNC/SS1 RPINR21.0 = 0 RPINR21.1 = 1 RPINR21.2 = 0 RPINR21.3 = 0 RPINR21.4 = 1 RPINR21.5 = 1 RPINR21.6 = 0 SPI1STAT.15 = 1 'SPI1 enabled Set PORTC.2 'SYNC Symbol DTA = PORTA.2 Symbol CLK = PORTD.10 Symbol RDY = PORTD.11 MAIN: dac_data = 00011111001111 Set RDY Low PORTC.2 DelayUS 1 SHOut PORTA.2, PORTD.10 , MsbFirst_H, [11111111111111\16] DelayUS 1 Set PORTC.2 Low RDY GoTo MAIN
    Last edited by tadd; 11th July 2016 at 09:09.

  • 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.

  • #6
    Fanatical Contributor top204's Avatar
    Join Date
    Feb 2002
    Posts
    3,404
    Thumbs Up
    Received: 290
    Given: 141
    Total Downloaded
    1.68 GB

    0 Not allowed!

    Default Re: PIC24EP SPI problem

    Why are you setting up the SPI peripheral and the PPS, then using the Shout command?

    The SHout and Shin commands are bit-bashed and do not use the MSSP peripheral at all.

    It is possible, in fact probable, that you're actually switching on a peripheral that is interfering with a pin that needs to operate in standard digital mode. If the PPS has switched a pin to a peripheral, it will no longer operate as a standard digital pin.
    Last edited by top204; 11th July 2016 at 10:52.

  • 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
    Senior Member tumbleweed's Avatar
    Join Date
    May 2011
    Posts
    485
    Thumbs Up
    Received: 59
    Given: 0
    Total Downloaded
    330.54 MB

    0 Not allowed!

    Default Re: PIC24EP SPI problem

    It looks like you're expecting Shout to use the SPI peripheral. It doesn't... it generates the outputs by bit-banging the pins.

    Remove all the SPI and PPS setup commands and see if it works.

    edit: Oops... too late.

  • 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.

  • #8
    tadd
    Guest tadd's Avatar

    0 Not allowed!

    Default Re: PIC24EP SPI problem

    i try the use spi peripheral and pps settings may be i can see clock but fail, without spi peripheral and pps settings, no clock , i see data cycle but there is not clock portd.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.

  • #9
    tadd
    Guest tadd's Avatar

    0 Not allowed!

    Default Re: PIC24EP SPI problem

    is there spi.inc file for spi ? i have clock problem and i can't use digital potentiometer

  • 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. pic24EP timer macros and example
      By tadd in forum Absolute Beginners Section
      Replies: 4
      Last Post: 18th February 2017, 17:05
    2. PIC24EP SPI Write Timing CPOL = 0 CPHA =1
      By tadd in forum Proton 24
      Replies: 7
      Last Post: 15th August 2016, 12:43
    3. [SOLVED !] 18F45K22 SPI Problem
      By roger in forum Proton Plus Compiler v3
      Replies: 3
      Last Post: 8th December 2011, 00:31
    4. SPI problem ,, its a dewsey
      By Maverick in forum The Lounge
      Replies: 17
      Last Post: 2nd January 2008, 22:07
    5. [SOLVED !] Strange SPI problem
      By dmTulsa in forum Proton Plus Compiler v3
      Replies: 2
      Last Post: 1st March 2007, 12:20

    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