Usage example
Add array data by Data addition mode and get the result when the result is larger than “FFFFh”.
After that, change the mode to Data comparision mode and generate interrupt when detecting the data other than “0000h”.
[GUI setting example]
Data operation circuit |
||||
DOC |
Used | |||
DOC setting |
Used | |||
Data operation setting |
Data addition mode | |||
COmparision reference/Initial value of addition or subtraction result |
0xFFFF | |||
Enable data operation circuit interrupt (INTDOC) |
Used | |||
INTDOC Priority |
Low |
[API setting example]
r_cg_main.c
/* Start user code for global. Do not edit comment generated here */
extern volatile uint16_t data[16];
volatile uint8_t cnt;
/* End user code. Do not edit comment generated here */
void main(void)
{
R_MAIN_UserInit();
/* Start user code. Do not edit comment generated here */
while (1U)
{
for (cnt = 0; cnt < 16U; cnt++)
{
/* Write new data to compare */
R_DOC_WriteData(data[cnt]);
}
}
/* End user code. Do not edit comment generated here */
}
r_cg_doc_user.c
/* Start user code for global. Do not edit comment generated here */
volatile uint16_t data[16];
volatile uint16_t result;
/* End user code. Do not edit comment generated here */
static void __near r_doc_interrupt(void)
{
/* Start user code. Do not edit comment generated here */
/* Get result */
R_DOC_GetResult((uint16_t *)&result);
/* Configure the operation mode of DOC */
R_DOC_SetMode(COMPARE_MISMATCH, 0x0000);
/* Clear DOPCF flag */
R_DOC_ClearFlag();
/* End user code. Do not edit comment generated here */
}