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 interface to the new At45db081b

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



Joined: 11 Feb 2004
Posts: 2

View user's profile Send private message

SPI interface to the new At45db081b
PostPosted: Wed Feb 11, 2004 2:47 am     Reply with quote

I am have a problem interfacing to the new at45db081b chip from atmel, I seem to be 1bit out in the return string, any pointers


Many thanks
Gary
Neutone



Joined: 08 Sep 2003
Posts: 839
Location: Houston

View user's profile Send private message

PostPosted: Wed Feb 11, 2004 1:34 pm     Reply with quote

Does the chip clock on the low to high or the high to low?
colortech



Joined: 11 Feb 2004
Posts: 2

View user's profile Send private message

PostPosted: Wed Feb 11, 2004 6:31 pm     Reply with quote

The chip clocks High to Low
Guest








PostPosted: Thu Feb 12, 2004 6:35 am     Reply with quote

Hello,

I use a " AT45DB321B " with the port spi of the PIC18F452

//----------------------------------------------------------------------------
// DataFlash AT45DB321B Hardware SPI Test
//
#include <18F452.h>
#device adc=8
#use delay(clock=40000000)
#fuses H4,NOWDT,NOPROTECT,NOLVP
#use rs232(baud=115200,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)

//----------------------------------------------------------------------------
// DTF_PINS Setting
//
#define DTF_CLK PIN_C3 // DTF Pin Clock
#define DTF_SO PIN_C4 // DTF Pin Sortie SPI de la DataFlash
#define DTF_SI PIN_C5 // DTF Pin Entree SPI de la DataFlash
#define DTF_READY PIN_E1 // DTF Pin Ready
#define DTF_CS PIN_E2 // DTF Pin Chip select

//----------------------------------------------------------------------------
// DTF MACRO
//
#define DTF_SELECT() output_low(DTF_CS)
#define DTF_UNSELECT() output_high(DTF_CS)
#define DTF_IS_READY() (input(DTF_READY))

//----------------------------------------------------------------------------
// TRIS
//
#define TRIS_E 0b00000010 // Tris du port E
#define TRIS_C 0b10010110 // Tris du port C

//----------------------------------------------------------------------------
// Fast IO
//
#USE fast_io(E)
#USE fast_io(C)

//----------------------------------------------------------------------------
void DTFInit()
{
output_high(DTF_CS);
output_high(DTF_CLK);
output_low(DTF_SI);
}
//----------------------------------------------------------------------------
BYTE DTF_ReadStatus()
{
BYTE Status;
//--- Select
DTF_SELECT();
//--- Command Read Status
spi_write(0x57);
//--- Status Result
Status = spi_read(0);
//--- Unselect
DTF_UNSELECT();
return (Status);
}
//----------------------------------------------------------------------------
void HwInit()
{
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_psp(PSP_DISABLED);
setup_wdt(WDT_OFF);
setup_timer_0(RTCC_INTERNAL);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
//--- Hardware SPI Setup
setup_spi(SPI_MASTER|SPI_H_TO_L|SPI_CLK_DIV_4|SPI_SAMPLE_AT_END);
//--- Tris port E
set_tris_e(TRIS_E);
//--- Tris port C
set_tris_c(TRIS_C);
//--- DataFlash Initialisation
DTFInit();
//--- Interrupts ON
enable_interrupts(global);
}
//----------------------------------------------------------------------------
void main()
{
//--- Initialisation
HwInit();
printf("TDF_Test...\r\n");
while(1) {
if (kbhit()) {
switch (getc()) {
case 't'://Test bit DTF_Ready
if (DTF_IS_READY())
printf("DTF_READY\r\n");
else
printf("DTF_NOT_READY\r\n");
break;
case 's':// Status
printf("Status :%x\r\n",DTF_ReadStatus());
break;
}// End Switch
}// End IF
}// End IF
}
//----------------------------------------------------------------------------
Guest








PostPosted: Fri Feb 13, 2004 11:22 am     Reply with quote

Thank You
Charlie U



Joined: 09 Sep 2003
Posts: 183
Location: Somewhere under water in the Great Lakes

View user's profile Send private message

spi setup
PostPosted: Fri Feb 13, 2004 9:17 pm     Reply with quote

Check this older post regarding general spi setup:

http://www.ccsinfo.com/forum/viewtopic.php?t=17922
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