Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Modify the C program in order to read, erase and write Texas Instruments SM28VLT32-HT, 32 Mbits Flash memory with SPI. Note that the address is

Modify the C program in order to read, erase and write Texas Instruments SM28VLT32-HT, 32 Mbits Flash memory with SPI.

Note that the address is a 21-bit word address. ( A word consists of two bytes.)

The data is 16-bit data for read and write operations.

(1)unsigned int readSPI_Flash(long unsigned int address);

(2) void SPI_writeSPI_Flash(long unsigned int address, unsigned int data);

(3)void SPI_eraseSegment(long unsigned int address);

Here is the code:

image text in transcribedimage text in transcribedimage text in transcribed

void main() unsigned char inputSPIO to initialize, and transmit and receive //to receive a byte via SPI using SPI if (SSPSTATbits.BF) unsigned int data; wait until SPI transfer is complete initialization while (1) data SSPBUF receive a byte. input 0; else data NULL data calculate0; return data output data); void initialization0 void outputSPI(unsigned char data) set up MSSP //to transmit a byte via SPI SSPSTAT XC0, rising edge to shift data SSPCON1 0x21; //enable SPI data rate 2 Mbps TRISCbits TRISC5 -0; //configure SDO as output transmit a byte TRISCbits.TRISC3 0; ///configure SCK as output while(ISSPSTATbits.BF TRISCbits.TRISC4-1; /configure SDI for input wait until SPI transfer is complete TRISBbits.TRISB0 0: configure CS as output TRISBbits.TRISB1 0; config, LDAC as output void main() unsigned char inputSPIO to initialize, and transmit and receive //to receive a byte via SPI using SPI if (SSPSTATbits.BF) unsigned int data; wait until SPI transfer is complete initialization while (1) data SSPBUF receive a byte. input 0; else data NULL data calculate0; return data output data); void initialization0 void outputSPI(unsigned char data) set up MSSP //to transmit a byte via SPI SSPSTAT XC0, rising edge to shift data SSPCON1 0x21; //enable SPI data rate 2 Mbps TRISCbits TRISC5 -0; //configure SDO as output transmit a byte TRISCbits.TRISC3 0; ///configure SCK as output while(ISSPSTATbits.BF TRISCbits.TRISC4-1; /configure SDI for input wait until SPI transfer is complete TRISBbits.TRISB0 0: configure CS as output TRISBbits.TRISB1 0; config, LDAC as output

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data, Mining, And Analytics Components Of Strategic Decision Making

Authors: Stephan Kudyba

1st Edition

1466568704, 9781466568709

More Books

Students also viewed these Databases questions