The following sequence is a basic example to scroll the string “HELLO WORLD ” by using the ACM scrolling mode in Segment LCD1 Xplained Pro LCD glass.
Buffers used :
/* DMA buffer length */ #define BUFFER_LEN 30 /* DMA resource and descriptor */ struct dma_resource example_resource; COMPILER_ALIGNED(16) DmacDescriptor example_descriptor; static char user_scrolling_str[BUFFER_LEN] = {"HELLO WORLD "}; static volatile uint32_t dma_source_buf[BUFFER_LEN]; static volatile bool transfer_is_done = false; static volatile uint32_t dma_break = 0, dma_block_count = 0;
slcd_disable();
xpro_lcd_clear_all();
user_scrolling_str[]
to dma_source_buf[]
This step includes the conversion of the ASCII value of each
character in the Scrolling string user_scrolling_str[]
into
equivalent segment value from the lookup table array DIGI_LUT[]
and find the block count. (Refer to Figure 2 to find the segment values different
characters.)
is_scrolling
, get the default configuration of ACM mode, and
load the configuration structure with the following configuration parameters for the
ACM scrolling
mode:/*Structure for the ACM configurations */
struct slcd_automated_char_config automated_char_config;
/** CMCFG.DEC = 0 CMCFG.NSEG = 3 ACMCFG.NDROW = 5 ACMCFG.STSEG = 4
* ACMCFG.NDIG = 5 ACMCFG.STEPS = string length - NDIG + 1
* ACMCFG.MODE = 1 ACMCFG.FCS = 1 */
if(true == is_scrolling ){
/*configuration for Auto character mapping scrolling mode */
/* Get default config for the ACM mode */
slcd_automated_char_get_config_default(&automated_char_config);
/* Segment mapping order (CMCFG.DEC bit) */
automated_char_config.order = 0;
/** select the number of segment used per digit
* it equal to number of SEG line - 1 (CMCFG.NSEG) */
automated_char_config.seg_line_num = 3;
/* Define the number of digit per row. (ACMCFG.NDROW) */
automated_char_config.row_digit_num = 5;
/** Define the index of the first segment terminal of the
* digit to display (ACMCFG.STSEG) */
automated_char_config.start_seg_line = 4;
/** Define the number of digit, it must be greater than 1.
* (ACMCFG.NDIG)*/
automated_char_config.digit_num = 5;
/* STEPS = string length - NDIG + 1 (ACMCFG.STEPS) */
automated_char_config.scrolling_step = dma_block_count – 5 + 1;
/* Select the ACM mode (ACMCFG.MODE) */
automated_char_config.mode = SLCD_AUTOMATED_CHAR_SCROLL;
/* Select the frame counter for the ACM mode (ACMCFG.FCS) */
automated_char_config.fc = SLCD_FRAME_COUNTER_1;
/*Configure the mask value in the CMDMASK register */
automated_char_config.data_mask = 0x00FF4002;
}
/* write the SLCD ACM configurations in the respective registers */
slcd_automated_char_set_config(&automated_char_config);
/* write the SLCD ACM configurations in the respective registers */
slcd_automated_char_set_config(&automated_char_config);
/* Set the frame counter configurations and enable it */
slcd_set_frame_counter(automated_char_config.fc,0,0x1);
slcd_enable_frame_counter(automated_char_config.fc);
slcd_enable();
is_scrolling
,
and load the configuration structure with the following configuration parameters for
the ACM scrolling
mode:/* Structure for the DMA resource configurations */
struct dma_resource_config config;
/* Get the default configuration */
dma_get_config_defaults(&config);
if( true == is_scrolling ){
/* Set the peripheral trigger source */
config.peripheral_trigger = SLCD_DMAC_ID_ACMDRDY;
/* Set the trigger action */
config.trigger_action = DMA_TRIGGER_ACTON_BEAT;
}
configure_dma_resource(&example_resource);
is_scrolling
, get the default configuration of DMA resource
configuration, and load the configuration structure with the following configuration
parameters for the ACM scrolling
mode:/* Structure for the DMA descriptor configurations */ struct dma_descriptor_config descriptor_config; if( true == is_scrolling ){ /* Get the default configuration */ dma_descriptor_get_config_defaults(&descriptor_config); descriptor_config.beat_size = DMA_BEAT_SIZE_WORD; descriptor_config.src_increment_enable = true; descriptor_config.dst_increment_enable = false; descriptor_config.step_size = (DMA_ADDRESS_INCREMENT_STEP_SIZE_1); descriptor_config.step_selection = DMA_STEPSEL_SRC; descriptor_config.block_action = DMA_BLOCK_ACTION_INT; /* Block count manipulated run time from the scrolling string */ descriptor_config.block_transfer_count = dma_block_count; descriptor_config.source_address = (uint32_t)dma_source_buf + (dma_block_count * sizeof(dma_source_buf[0])); descriptor_config.destination_address = (uint32_t)(&SLCD->CMDATA.reg); descriptor_config.next_descriptor_address =( uint32_t )descriptor; /* Create a DMA descriptor */ dma_descriptor_create(descriptor, &descriptor_config); }
configure_dma_descriptor(&example_resource);
dma_register_callback(&example_resource, dma_callback,DMA_CALLBACK_TRANSFER_DONE);
dma_enable_callback(&example_resource, DMA_CALLBACK_TRANSFER_DONE);
/** Start DMA transfer once DMA gets the peripheral
* trigger form the ACM then the data transfer starts */
dma_start_transfer_job(&example_resource);
/* Enable ACM mode */
slcd_enable_automated_character();