CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug Reports on this forum. Send them to support@ccsinfo.com

SPI problem with PIC24EP512GP202

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
pbraida



Joined: 02 Feb 2011
Posts: 14

View user's profile Send private message

SPI problem with PIC24EP512GP202
PostPosted: Fri May 17, 2019 8:47 am     Reply with quote

Hello all.

Anybody can help me?

My compiler version is 5.085.
The pic is PIC24EP512GP202.

The problem is:

I made a test program to send bytes by SPI1.
The SPI1 pins are connected to a scope only.
I can saw the clock signs perfectly, but nothing in DO pin.

My setup is:
Code:

#include <24EP512GP202.h>

#device ICSP=3
#use delay(clock=140000000,crystal=8000000,restart_wdt)

#FUSES NOWDT                    //Watch Dog Timer
#FUSES WPRES32                  //Watch Dog Timer PreScalar 1:32
#FUSES WPOSTS11                 //Watch Dog Timer PostScalar 1:1024
#FUSES JTAG                     //JTAG enabled
#FUSES WDTWIN_25%               //Watchdog Window is 25% of WDT period
#FUSES PLLWAIT                  //Clock switch to PLL will wait until the PLL lock signal is valid
#FUSES WINDIS                   //Watch Dog Timer in non-Window mode
#FUSES OSCIO                    //OSC2 is general purpose output
#FUSES IOL1WAY                  //Allows only one reconfiguration of peripheral pins
#FUSES NOCKSNOFSM               //Clock Switching is disabled, fail Safe clock monitor is disabled
#FUSES PR_PLL
#FUSES HS

#use spi(FORCE_HW,MASTER,SPI1,MODE=0,BITS=8,stream=SPI_PORT1,BAUD=1600000,DI=PIN_B9,DO=PIN_B8,CLK=PIN_B7)

void main() {

   while(TRUE) {
 
      spi_xfer(SPI_PORT1,0x0a); 

      output_high(pin_b4);// The led connected in this pins worked perfecly.
      delay_ms(100);
      output_low(pin_b4);
      delay_ms(100);

   }

}
Ttelmah



Joined: 11 Mar 2010
Posts: 14611

View user's profile Send private message

PostPosted: Fri May 17, 2019 10:38 am     Reply with quote

A peripheral, overrides all digital I/O on the pin, but will not override
analog features. If you look, the SDO1 pin, is shared with the comparator1
voltage reference output. Turn this off with the setup_vref instruction.

You also have JTAG enabled. The SDO1 pin is the JTAG test clock pin.
This will override the SPI peripheral on this. Have you genuinely got a JTAG
interface debugger?. If you are using this, SDO1 is not available for you.
pbraida



Joined: 02 Feb 2011
Posts: 14

View user's profile Send private message

PostPosted: Fri May 17, 2019 11:26 am     Reply with quote

Ttelmah, thanks a lot.
I thought the #use spi, did this for me.

Thanks again.

Pedro.
Ttelmah



Joined: 11 Mar 2010
Posts: 14611

View user's profile Send private message

PostPosted: Fri May 17, 2019 11:40 am     Reply with quote

It can't turn off fuses.
There is an assumption that if you are setting JTAG, it is because you
are using this.

Generally, the compiler in most versions defaults to disabling the ADC,
but in some cases it will 'miss' things like the comparator voltage reference,
so if it doesn't work, the first thing to do is turn off everything that might
cause an issue. In your case, JTAG _will_ stop it working.
Why have you got this on?. 99.999% of systems do not want this. The
only time this would want to be 'on' is the very specific thing of a system
using a JTAG programmer or debugger. In this case, this pin will be wired
to the JTAG header, so it'll be obvious that there is a problem...
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group