K22FN256 - Writing to External EEPROM

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

K22FN256 - Writing to External EEPROM

843 Views
briancavanagh
Contributor III

Hi, as you see above I'm using the K22FN256 uC and attached to pins 49 - 52 (SPI) is an EEPROM chip (Adesto Technologies, Digikey Part Number: 1265-1147-1-ND ).   I'm not clear how to get started writing to EEPROM.

I understand the CS', followed by SCK, followed by SO or SI is important.

I also understand there's OPCodes that are used to Read/Write and/or Erase the EEPROM.  

I'm not sure how to setup a function that can carry this out.  Can someone offer any suggestions?

Thanks,

Brian

Labels (1)
0 Kudos
4 Replies

599 Views
mjbcswitzerland
Specialist V

Brian

This device is an SPI Flash.
I have attached the driver for this from the uTasker project (it is compatible with ST parts as far as I can see - it just needs the manufacturer IDs changed) along with the generic flash driver (which allows it to look like a memory mapped device - like a linear extension to the internal Flash).

There are 5 such SPI Flash drivers in the Open Source project for the K22 and if you run it in Visual Studio it will also emulate the SPI chips so that you can see how they interact (Kinetis SP <-> SPi Flash) and test complete application based on it.

Regards

Mark

Kinetis: http://www.utasker.com/kinetis.html
Kinetis K22:
- http://www.utasker.com/kinetis/TWR-K22F120M.html
- http://www.utasker.com/kinetis/BLAZE_K22.html
- http://www.utasker.com/kinetis/BLAZE_K22.html
Flash interface (including SPI flash): http://www.utasker.com/docs/uTasker/uTaskerFileSystem_3.PDF
Virtual memory mapping of flex data (and serial memory) video:
- https://youtu.be/Pe9A8qsefzQ

Free [FREE FREE FREE FREE - so nothing to be scared of !!!] Open Source solution: https://github.com/uTasker/uTasker-Kinetis
Working project in 15 minutes video: https://youtu.be/K8ScSgpgQ6M

Professional Kinetis support, one-on-one training and complete fast-track project solutions: http://www.utasker.com/support.html

0 Kudos

599 Views
briancavanagh
Contributor III

Below is my components section:

pastedImage_2.png

0 Kudos

599 Views
mjbcswitzerland
Specialist V

Hi Brian

Sorry but I can't help with the component inspector - but it is only generating a few lines of code for you (which you should also understand if you are going to be responsible for a product development).

As reference, it equates to something like this (5 lines of code):

_CONFIG_PERIPHERAL(C, 4, (PC_4_SPI0_PCS0 | PORT_SRE_FAST | PORT_DSE_HIGH));
_CONFIG_PERIPHERAL(C, 5, (PC_5_SPI0_SCK | PORT_SRE_FAST | PORT_DSE_HIGH));
_CONFIG_PERIPHERAL(C, 6, (PC_6_SPI0_SOUT | PORT_SRE_FAST | PORT_DSE_HIGH));
_CONFIG_PERIPHERAL(C, 7, PC_7_SPI0_SIN);
SPI0_MCR = (SPI_MCR_MSTR | SPI_MCR_DCONF_SPI | SPI_MCR_CLR_RXF | SPI_MCR_CLR_TXF | SPI_MCR_PCSIS_CS0 | SPI_MCR_PCSIS_CS1 | SPI_MCR_PCSIS_CS2 | SPI_MCR_PCSIS_CS3 | SPI_MCR_PCSIS_CS4 | SPI_MCR_PCSIS_CS5);
SPI0_CTAR0 = (SPI_CTAR_DBR | SPI_CTAR_FMSZ_8 | SPI_CTAR_PDT_7 | SPI_CTAR_BR_2 | SPI_CTAR_CPHA | SPI_CTAR_CPOL); // for 50MHz bus, 25MHz speed and 140ns min de-select time

In some cases it is easier and faster to write a few lines of code that one then understands, one can manage and which can also be discussed.

Regards

Mark

0 Kudos

599 Views
briancavanagh
Contributor III

Hi Mark, I'm finding it confusing to use these recommendations, but thank you for responding.

I'm using KDS and want to setup SPI0:Init_SPI ?  There are questions I'm not clear on how to answer.

Below is just a screen capture of the settings tab.  Is there any examples on how to set this up using the 'Components Inspector' ?

Thanks again,

Brian

pastedImage_1.png

0 Kudos