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

SPI2 read does not work on dsPIC30F6014A

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



Joined: 27 May 2004
Posts: 12
Location: Austria

View user's profile Send private message Send e-mail

SPI2 read does not work on dsPIC30F6014A
PostPosted: Thu Oct 27, 2011 7:52 am     Reply with quote

Hello,

I do a simple read on the SPI2 of a dsPIC30F6014A.
No way to get it run - the read value is always 0x00.

Here is the code snippet of some settings:
Code:

/*                                                 */
/* global header                                    */
/* YUM                                             */
/* global.h, 06/11                                    */
/* compile with CCS - 4.119, MPLAB 8.76                     */


#include   <30F6014A.h>
#device *=16 adc=12

// due to a silicon bug of the PIC processor, the fuses are set manually:
#FUSES 1=0x8705
#FUSES 2=0x003F
#FUSES 3=0x87A3
#FUSES 4=0x310F
#FUSES 5=0x330F
#FUSES 6=0x0007
#FUSES 7=0xC003

#ZERO_RAM


#define VERSION 0x0611
#define Fosc 40000000

#ID VERSION
#TYPE  SHORT=8, INT=16, LONG=32
#USE FIXED_IO(a_outputs=PIN_A6, PIN_A7, PIN_A9, PIN_A10, PIN_A13, PIN_A14, PIN_A15)
#USE FIXED_IO(b_outputs=PIN_B2, PIN_B3, PIN_B5, PIN_B6, PIN_B7, PIN_B8, PIN_B9, PIN_B10, PIN_B11, PIN_B14)
#USE FIXED_IO(c_outputs=PIN_C1, PIN_C2, PIN_C3, PIN_C4)
#USE FIXED_IO(d_outputs=)
#USE FIXED_IO(f_outputs=PIN_F6, PIN_F8)
#USE FIXED_IO(g_outputs=PIN_G6, PIN_G8, PIN_G9, PIN_G15)
#USE delay(clock = Fosc)
#use rs232(baud=9600, UART1, parity=N,bits=8)[b]




Here is the code snippet of the subroutine:

Code:
//------------------------------------------------------------------------
// read the keypad
char up_key_read_the_keypad(void)
 {
 char read_value;
 setup_spi2(spi_master | SPI_MODE_0 |spi_clk_div_128 | SPI_MODE_8B);
 CS_KEY_OFF();
 CS_KEY_ON();
 delay_us(10);
 read_value = spi_read2(0xf3);
 delay_us(10);
 CS_KEY_OFF();

printf("  read value: %02X\r\n", read_value);

 return read_value;
 }
/*---------------------------------------------------------*/




Here is the screenshot of the signals and the serial test-output:



As you can see, all signals are present; the serial input (miso) is NOT static 0,
but most of the time 1
, so changing the spi modes will not help.
The spi is even running very slowly.

Any ideas?
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Thu Oct 27, 2011 8:29 am     Reply with quote

I don't see SPI_MODE_0 defined in your code, thus I wonder what's missing else. But there's no obvious reason, why spi_read2 should read 0x00 with the shown waveforms, provided you connected the right SDI2 pin.
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