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

Driver /help required for atmel AT45DB041B

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







Driver /help required for atmel AT45DB041B
PostPosted: Thu Jan 30, 2003 11:34 pm     Reply with quote

Hi all
I am having little or no response from the chip. I am using the 8 pin device and currently cant even read the status so this makes the driver debugging very difficult. I have interfaced directly to an 16f877 using the hardware SP interface.
So if anybody has a driver i can share or some pointers please help.

thanks in advance
regards
Rob Sterling
___________________________
This message was ported from CCS's old forum
Original Post ID: 11145
Joe Heinrich
Guest







Driver /help required for atmel AT45DB041B
PostPosted: Fri Jan 31, 2003 8:32 am     Reply with quote

:=Hi all
:=I am having little or no response from the chip. I am using the 8 pin device and currently cant even read the status so this makes the driver debugging very difficult. I have interfaced directly to an 16f877 using the hardware SP interface.
:=So if anybody has a driver i can share or some pointers please help.
:=
:=thanks in advance
:=regards
:=Rob Sterling

Here is code I wrote using CCS 2.XXX and MPLAB 5.01(I think).
It gives you basic functionality.

//this is to develope code for spi to atmel 45db321 memory. 10-20-2001
//10.26.2001 this works for getting the status out of the
// memory so it should be easy to get spi working for
//the other commands.

#include <16f877.h>
#include <stdlib.h>


#DEVICE PIC16F877 *=16 ICD=TRUE

#use delay (clock=2457600)
#use fast_io(a)
#use fast_io(b)
#use fast_io(c)
#use fast_io(d)
#use fast_io(e)

#define flash_ready_busy_pin pin_c2
#define flash_cs_pin pin_d2

//flash commands for Atmel at45db321
#define main_read 0x52
#define read_buff1 0x54
#define read_buff2 0x56
#define main_to_buff1 0x53
#define main_to_buff2 0x55
#define main_to_buff1_compare 0x60
#define main_to_buff2_compare 0x61
#define write_buff1 0x84
#define write_buff2 0x87
#define buff1_to_main 0x83
#define buff2_to_main 0x86
#define main_write_thru_buff1 0x82
#define main_write_thru_buff2 0x85
#define page_erase 0x81
#define block_erase 0x50
#define status_reg 0x57


#define SSPCON 0x0014

#byte TRISC = 0x0087
#byte TRISD = 0x0088

#byte sspstat = 0x0094
#define bf 0

void cs_low();
int spi_write1(spi_data);

////////////////////////////////////

int spi_write1(spi_data)
{
spi_write(spi_data);
}

////////////////////////////////////

void cs_low() //select the flash
{
output_low(flash_cs_pin);
}

////////////////////////////////////

void cs_high() //deselect and close flash
{

//might need to check sspstat,bf

output_high(flash_cs_pin);
}

////////////////////////////////////

main()
{
int flash_temp;
set_tris_c(0b11010111); //spi,timer1,tx,rx

set_tris_d(0b11111011); //memory control

setup_spi(spi_master|spi_h_to_l|spi_clk_div_4);
output_high(flash_cs_pin);
output_low(flash_cs_pin);
spi_write(0x57);
spi_write(0x55);
flash_temp=spi_read();
while (!bit_test(sspstat,bf));
cs_high();

cs_low();
spi_write1(write_buff1);
spi_write1(0x7f);
spi_write1(0xf8);
spi_write1(0);
spi_write1(11);
while (!bit_test(sspstat,bf));
cs_high();

cs_low();
spi_write1(read_buff1);
spi_write1(0x7f);
spi_write1(0xf8);
spi_write1(0);
spi_write1(10);
spi_write1(10);
spi_write1(10);
flash_temp = spi_read();
spi_write1(10);
flash_temp = spi_read();
spi_write1(10);
flash_temp = spi_read();
while (!bit_test(sspstat,bf));
cs_high();

cs_low();
spi_write(buff1_to_main);
spi_write1(0x7f);
spi_write1(0xf8);
spi_write1(0);
while (!bit_test(sspstat,bf));
cs_high();

cs_low();
spi_write1(main_read);
spi_write1(0x7f);
spi_write1(0xf8);
spi_write1(0);
spi_write1(00);
spi_write1(00);
spi_write1(00);
spi_write1(00);
spi_write1(00);
flash_temp=spi_read();
return(spi_read());

}
___________________________
This message was ported from CCS's old forum
Original Post ID: 11158
Charlie U
Guest







Re: Driver /help required for atmel AT45DB041B
PostPosted: Fri Jan 31, 2003 1:36 pm     Reply with quote

:=Hi all
:=I am having little or no response from the chip. I am using the 8 pin device and currently cant even read the status so this makes the driver debugging very difficult. I have interfaced directly to an 16f877 using the hardware SP interface.
:=So if anybody has a driver i can share or some pointers please help.
:=
:=thanks in advance
:=regards
:=Rob Sterling

Following the link below and dig deeper. This may have an answer to your problem.
___________________________
This message was ported from CCS's old forum
Original Post ID: 11171
rob
Guest







Re: Driver /help required for atmel AT45DB041B
PostPosted: Tue Feb 04, 2003 12:20 am     Reply with quote

Hi

Thanks for the help - i found my problem it was thee spi setup i had
setup_spi(spi_master|spi_l_to_h|spi_clk_div_4); and spi-read();
and the fix is
setup_spi(spi_master|spi_h_to_l|spi_clk_div_4); and sip_read(0);
___________________________
This message was ported from CCS's old forum
Original Post ID: 11253
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