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

PIC with SST25PF080B and CCS driver SST25vf.c

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



Joined: 10 Feb 2014
Posts: 4
Location: Switzerland

View user's profile Send private message

PIC with SST25PF080B and CCS driver SST25vf.c
PostPosted: Mon Feb 10, 2014 7:06 am     Reply with quote

Hi all,

I use the Flash Memory SST25PF080B and I use also the CCS Driver SST25vf.c, which is included in the CCS Compiler (V 4.134) driver folder.
My problem is, that i can write into and read from the Flash, but the chars they comes back are not correct.

For example: if I write 5 times the char 'h', the returned chars are "B B B B G" (Hex 42 42 42 42 47).
And the output of "Hello" returns Hex "04 4c 66 67 7f"

Any idea? Thank you very much for help!

Greets, Odroda

I have changed only two lines in the original CCS driver:
Code:

#define FLASH_SIZE         8388608

#define FLASH_SELECT_PIN PIN_C0         //my SST25 CE Pin


The initialisation of the SPI is like default in the CCS driver:
Code:

#use spi(spi1, MODE=0, BITS=8, STREAM=FLASH_STREAM, FORCE_HW)


For the first tests, i have written the following Main:
Code:

//File:         main.c
//Autor:        CJ
//Date:         08.02.2014
//------------------------------------------------------------------------------------
// ------- Include_und_Globale_Definitionen------------------------------------#include "16F876A.H"
#include "stdlib.h"

#fuses   hs, nowdt, noprotect, put, nobrownout, nolvp
#use delay (clock = 8000000)

#include "SST25vf.c"

#INT_GLOBAL
#use standard_io(A)
#use standard_io(B)
#use standard_io(C)

#use rs232(baud=19200, xmit=PIN_C6, rcv=PIN_C7, parity=n, bits=8)

char Read;

#define  CE    pin_c0
#define  WP    pin_c1
#define  Hold  pin_c2
#define  SCK   pin_c3
#define  SDI   pin_c4
#define  SDO   pin_c5

// -------Deklaration_der_verschiedenen_Module-------------------------------------------------

   void MAIN(void);

// -------Hauptprogramm------------------------------------------------------------------------

void MAIN(void)
{   
    FLASH_DESELECT();

    output_high(Pin_A0);      // Power on SST25

    delay_ms(100);

    output_high(WP);     
    output_high(Hold);
                       
    ext_flash_init();

    ext_flash_protect(FLASH_PROTECT_NONE);
                     
    ext_flash_bulk_erase();
    delay_ms(500);

    ext_flash_write_byte(0x000030, 'H');
    ext_flash_write_byte(0x000031, 'e');
    ext_flash_write_byte(0x000032, 'l');
    ext_flash_write_byte(0x000033, 'l');
    ext_flash_write_byte(0x000034, 'o');

    Read = ext_flash_read_byte(0x000030);
    printf("%c ", Read);

    Read = ext_flash_read_byte(0x000031);
    printf("%c ", Read);

    Read = ext_flash_read_byte(0x000032);
    printf("%c ", Read);

    Read = ext_flash_read_byte(0x000033);
    printf("%c ", Read);

    Read = ext_flash_read_byte(0x000034);
    printf("%c ", Read);

  while(TRUE)
  {
  }
}
Ttelmah



Joined: 11 Mar 2010
Posts: 19520

View user's profile Send private message

PostPosted: Mon Feb 10, 2014 12:48 pm     Reply with quote

Ignoring anything else, why do you have a #INT_GLOBAL line?.
And, even worse, why where it is?.

This says that the function declared immediately after it, is the global interrupt handler. It must not exist without a function immediately after it, and will probably result in some function (probably part of the RS232!), being placed as the interrupt handler, when you don't use interrupts at all....
odroda



Joined: 10 Feb 2014
Posts: 4
Location: Switzerland

View user's profile Send private message

PostPosted: Mon Feb 10, 2014 11:28 pm     Reply with quote

Many thanks for your answer Ttelmah!

O, you're right. This line is too much. That comes from the copy and paste.
I've removed now. That alone has the problem not been solved.
odroda



Joined: 10 Feb 2014
Posts: 4
Location: Switzerland

View user's profile Send private message

PostPosted: Fri Feb 21, 2014 2:36 am     Reply with quote

I have tested the in- and outputs of the SST25PF080B with the Logic Analyzer.
The results can you see on bottom.

WP* = high
Hold* = high

ext_flash_init()

SDI 05 SDO 00 CE* = low //Read Status-Register
SDI 00 SDO 30 CE* = low
Idle CE* = high
SDI 04 SDO 00 CE* = low //Write Disable
Idle CE* = high
SDI 05 SDO 00 CE* = low //Read Status-Register
SDI 00 SDO 30 CE* = low
Idle CE* = high
SDI 80 SDO 00 CE* = low //Disable SO to Output RY/RB# status during AAI programming
Idle CE* = high


ext_flash_protect(FLASH_PROTECT_NONE)

SDI 05 SDO 00 CE* = low //Read Status-Register
SDI 00 SDO 30 CE* = low
Idle CE* = high
SDI 06 SDO 00 CE* = low //Write Enable
Idle CE* = high
SDI 05 SDO 00 CE* = low //Read Status-Register
SDI 00 SDO 38 CE* = low
Idle CE* = high
SDI 01 SDO 00 CE* = low //Write Satus-Register
SDI 00 SDO 00 CE* = low
Idle CE* = high
SDI 05 SDO 00 CE* = low //Read Status-Register
SDI 00 SDO 00 CE* = low
Idle CE* = high
SDI 06 SDO 00 CE* = low //Write Enable
Idle CE* = high
SDI 05 SDO 00 CE* = low //Read Status-Register
SDI 00 SDO 00 CE* = low
Idle CE* = high
SDI 01 SDO 00 CE* = low //Write Satus-Register
SDI 80 SDO 00 CE* = low //Disable SO to Output RY/RB# status during AAI programming
Idle CE* = high


ext_flash_write_byte(0x000030, 'h') //Write "h" in to adress 0x000030

SDI 05 SDO 00 CE* = low //Read Status-Register
SDi 00 SDO 00 CE* = low
Idle CE* = high
SDI 06 SDO 00 CE* = low //Write Enable
Idle CE* = high
SDI 05 SDO 00 CE* = low //Read Status-Register
SDI 00 SDO 00 CE* = low
Idle CE* = high
SDI 02 SDO 00 CE* = low //Program One Data Byte
SDI 00 SDO 00 CE* = low
SDI 00 SDO 00 CE* = low
SDI 30 SDO 00 CE* = low
SDI 68 SDO 00 CE* = low
Idle CE* = high


ext_flash_read_byte(0x000030) //Read Adress 0x000030

SDI 05 SDO 00 CE* = low //Read Status-Register
SDI 00 SDO 00 CE* = low
Idle CE* = high
SDI 03 SDO 00 CE* = low //Read Memory
SDI 00 SDO 00 CE* = low
SDI 00 SDO 00 CE* = low
SDI 30 SDO 00 CE* = low
SDI 00 SDO 07 CE* = low


Any idea?
Ttelmah



Joined: 11 Mar 2010
Posts: 19520

View user's profile Send private message

PostPosted: Fri Feb 21, 2014 3:56 am     Reply with quote

Several things:

You haven't told us what processor you are using?.
You don't show a processor file being included?.
It must be a 3.3v PIC, or level translators will be needed.

Then you are aware that SDO on the master (processor), connects to SDI on the memory (and vice versa). Calling the master output line 'SDI' in the logic analyser listing, makes me worry...

Then standard includes like stdlib, should always be _after_ the clock and serial (if being used), have been setup. Some things in these _depend_ on having the system configurations already made.

Then you don't need/want to change the original include file at all. Just set the pin you want to use, before you include the file. So:
Code:

#define FLASH_SELECT_PIN PIN_C0
#define FLASH_SIZE         8388608
#include "SST25vf.c"


changes the select pin,, and memory size without having to change the include file. This is documented in the file.
odroda



Joined: 10 Feb 2014
Posts: 4
Location: Switzerland

View user's profile Send private message

PostPosted: Mon Feb 24, 2014 5:39 am     Reply with quote

Dear Ttelmah,

We have an PIC16F876A and level shifter for all Connections (except the Data line from Flash to PIC).
The SDO from PIC is connected to SDI of the Flash and the SDO from Flash is connected to the PIC SDI Input.

Unfortunately your inputs didn't solve our problem. But thank you for your effort in helping to find a solution.
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