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

PIC18F452 and SPI

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



Joined: 28 Nov 2003
Posts: 39
Location: Essex UK

View user's profile Send private message

PIC18F452 and SPI
PostPosted: Wed May 31, 2006 11:52 am     Reply with quote

The following code repeatedly resets (on watchdog I assume).
If I remove the SPI write all is OK.
Chip errata dosen't metion SPI problems.
Any ideas.
Compiler version 3.241

Code:

#include <18F452.h>
#device ADC=10
#fuses  HS,NOPROTECT,PUT,WDT,WDT64,NOLVP,BROWNOUT,BORV45

#byte PORTA = 0xF80
#byte PORTB = 0xF81
#byte PORTC = 0xF82
#byte PORTD = 0xF83
#byte PORTE = 0xF84

#use delay(clock=20000000, RESTART_WDT)
#use rs232(baud=19200,xmit=PIN_C6,rcv=PIN_C7,errors)

#define IDDRA         0b00100000
#define IDDRB         0b00000011
#define IDDRC         0b10010000
#define IDDRD         0b11111111
#define IDDRE         0b00000000

#define IPORTA        0b00100100
#define IPORTB        0b00001000
#define IPORTC        0b10000000
#define IPORTD        0b00000000
#define IPORTE        0b00000111

#zero_ram


void main(void)
{
int16 k;
restart_WDT();

PORTA = IPORTA;
PORTB = IPORTB;
PORTC = IPORTC;
PORTD = IPORTD;
PORTE = IPORTE;
set_tris_a(IDDRA);
set_tris_b(IDDRB);
set_tris_c(IDDRC);
set_tris_d(IDDRD);
set_tris_e(IDDRE);

printf("Start\r");

setup_spi(0x0000 | SPI_XMIT_L_TO_H  | SPI_MASTER | SPI_L_TO_H | SPI_CLK_DIV_64 | SPI_SS_DISABLED);
while (1)
{
   restart_WDT();
   spi_write(0xD3);
   delay_ms(500);
   printf("Loop\r");
   }
}

ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Wed May 31, 2006 12:54 pm     Reply with quote

Remove the SPI_SS_DISABLED parameter, it is only allowed for SPI-slaves and messes up the SPI configuration.
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