User`s manual
RX62N Group, RX621 Group 5. Usage Examples
5.5.2. External bus, SDRAM area
Figure 5-7 shows an example of SDRAM bus controller usage, and the procedure for transition to and recovery
from self-refresh mode in deep software standby mode.
/* PDL functions */
#include "r_pdl_bsc.h"
#include "r_pdl_io_port.h"
#include "r_pdl_cgc.h"
#include "r_pdl_lpc.h"
#include "r_pdl_intc.h"
/* PDL device-specific definitions */
#include "r_pdl_definitions.h"
#define SELF_REFRESH_SELECT 1
void BSC_error_handler(void);
void NMI_handler_lpc(void);
void main(void)
{
uint32_t * sdram_location_32;
uint8_t status1, sdram_status;
uint16_t status2;
volatile uint32_t temp;
uint32_t i;
bool rtn;
uint16_t status_flags;
/* Point to respective external memory areas */
sdram_location_32 = (uint32_t *)0x08000000ul;
/* Configure the clocks and enable the BLCK output */
/* ICLK=96MHz, PCLK=48MHz, BCLK=12MHz, SDCLK=12MHz */
R_CGC_Set(
12E6,
96E6,
48E6,
12E6, PDL_CGC_BCLK_DIV_1 | PDL_CGC_SDCLK_ENABLE
);
/* Enable control of LED1 */
R_IO_PORT_Set(
PDL_IO_PORT_0_3,
PDL_IO_PORT_OUTPUT
);
/* Turn OFF LED1 */
R_IO_PORT_Write(
PDL_IO_PORT_0_3,
1
);
/* Configure the bus controller */
/* Select pin-B for CS1#~CS7#; enable SDRAM pins; enable error monitoring */
R_BSC_Create( \
PDL_BSC_CS1_B|PDL_BSC_CS2_B|PDL_BSC_CS3_B|PDL_BSC_CS4_B| \
PDL_BSC_CS5_B|PDL_BSC_CS6_B|PDL_BSC_CS7_B | PDL_BSC_WAIT_NOT_USED, \
PDL_BSC_SDRAM_PINS_ENABLE | PDL_BSC_SDRAM_DQM1_ENABLE, \
PDL_BSC_ERROR_ILLEGAL_ADDRESS_ENABLE | PDL_BSC_ERROR_TIME_OUT_ENABLE,
BSC_error_handler,
5
);
/* Configure SDRAM area */
R_BSC_SDRAM_CreateArea(
PDL_BSC_SDRAM_WIDTH_32| PDL_BSC_SDRAM_8_BIT_SHIFT,
R20UT0084EE0112 Rev.1.12 Page 5-11
July. 16, 2014