Question: 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:

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

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

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!