General operation of efm32-chip peripherals-MSC

Source: Internet
Author: User

Because the Flash cannot be read when the internal Flash is erased, otherwise the Flash will be stopped. Under normal circumstances, the interrupt vector table and the interrupt processing function are stored in Flash. Therefore, when the internal Flash is erased, the system will usually shut down the total interruption, temporarily not responding to the external interruption. In this way, the system only performs the write and erase operations, instead of reading commands in Flash. Therefore, the Flash operation is normal.

Hardware: TG STK

Software: For the purpose of testing, add the 1 ms timer generated by ick to the program. As a test condition. Used to test whether Flash operations are normal.

The specific Demo is as follows:

# Include <stdint. h>
# Include <stdio. h>
# Include <stdbool. h>
# Include "efm32.h"
# Include "efm32_chip.h"
# Include "efm32_cmu.h"
# Include "efm32_msc.h"

Volatile uint32_t msTicks;
Const unsigned char ucWriteIn [8] = {'A', 'B', 'C', 'D', 'E', 'F', 'G ', 'H ',};
Unsigned char ucReadOut [8];

Void javasick_handler (void)
{
MsTicks ++;
}

Void main (void)
{
CHIP_Init ();
/* Ensure core frequency has been updated */
SystemCoreClockUpdate ();

// Add a timer
If (SysTick_Config (SystemCoreClock/1000) while (1 );

MSC_Init (); // initialize MSC and enable AUXHFRCO

_ Disable_irq (); // close the total interruption.

If (MSC_ErasePage (uint32_t *) 0x0fe00000) = mscReturnOk)
{
MSC_WriteWord (uint32_t *) 0x0fe00000, ucWriteIn, 8 );
}

MSC_Deinit ();

Unsigned char * point = (unsigned char *) 0x0fe00000;
For (unsigned char I = 0; I <8; I ++)
{
If (* (point + I) = ucwritein [I]) continue;
Else
{
While (1); // error occur
}
}

_ Enable_irq (); // enable the total interrupt

While (1 );
}

As you can see, the Operation has been completed normally. Since it takes about 20 ms to erase data, and at least 20 US is required for each write of 4 bytes, this method is OK if it is not affected by 1 ms interruption.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.