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 CCS Technical Support

Why can't use the MSSP2 module for the SPI protocol

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



Joined: 01 Nov 2019
Posts: 1

View user's profile Send private message

Why can't use the MSSP2 module for the SPI protocol
PostPosted: Sat Nov 02, 2019 12:03 am     Reply with quote

Hi all,

I am using compiler CCS (v5.008) and MCU PIC18F46k22(has 2 MSSP module) , to display text in P10-DMD using MSSP2 module of the MCU.

---My target to use MSSP1 for hardware I2C (for RTC clock) and MSSP2 for hardware SPI (to display clock data in DMD).-----

For that, FIRST going to setup Hardware SPI for DMD with MSSP2 Module,

All things are going correct if MSSP1 is used with the code below SPI configuration---

Code:
#use SPI(SPI1, MODE = 0, BITS = 8, STREAM = P10_Panel_Driver)



But if MSSP2 is configured with below, then the MSSP2 for SPI is not working, even SCK2 pin is not responding.

Code:
#use SPI(SPI2, MODE = 0, BITS = 8, STREAM = P10_Panel_Driver)


Is this enough for SPI2 to work or anything else that I am missing?


Anyone can help me?

Thanks
Ttelmah



Joined: 11 Mar 2010
Posts: 19520

View user's profile Send private message

PostPosted: Sat Nov 02, 2019 12:08 am     Reply with quote

Both port have analog functions that have priority over their use
for SPI. The SPI1 port only has ADC pins and these are normally
turned off automatically. The SPI2 port has comparator functions on
the same pins, and this peripheral needs to be turned off.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Nov 02, 2019 1:11 am     Reply with quote

What PIC pin are you looking at with your oscilloscope to see the SCK2 signal ?

Post your code that sends a byte using the SPI2 module.
temtronic



Joined: 01 Jul 2010
Posts: 9229
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Nov 02, 2019 4:30 am     Reply with quote

couple of comments.
1) 5v008 is very early and may have a few 'bugs' in it...

2) It's always good to add 'Baud=rate' to the options. If NOT specified, the SPI will be clocked at the fastest rate possible. Some SPI devices won't work at very fast clock rates. If you add the option, you can SEE what the rate is.

Jay
Ttelmah



Joined: 11 Mar 2010
Posts: 19520

View user's profile Send private message

PostPosted: Sun Nov 03, 2019 3:31 am     Reply with quote

I've just checked, and your compiler does seem to be doing everything OK.
Code:

#include <18F46K22.h>      //
#fuses INTRC_IO       //Internal RC Osc, no CLKOUT                     
#fuses NOWDT, BROWNOUT, PUT, NOPBADEN, NOHFOFST                                     
#fuses NOMCLR                                           

#use delay(internal=4MHz)   //

#use SPI(SPI2, MODE = 0, BITS = 8, STREAM = P10_Panel_Driver)

void main() {       
   setup_comparator(NC_NC_NC_NC);
   setup_adc(NO_ANALOGS);
   while(true){            //Basic SPI test
      spi_xfer(P10_Panel_Driver, 0x55);
      delay_us(50);
   }
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Nov 03, 2019 3:51 am     Reply with quote

I looked at the .LST file a while ago and saw the same thing.
That's why I asked him what pin he was looking at when he
said it doesn't put out an SCK2 signal.
temtronic



Joined: 01 Jul 2010
Posts: 9229
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Nov 03, 2019 5:45 am     Reply with quote

Almost sounds like a a 'solder whisker' might be causing the problem ?
Perhaps cut small program to 'toggle' the I/O pin and use scope or LED to see if that works.

Jay
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