rz/a1h timer

hello friends,

i'm working on rz/a1h microprocessor in e2studio i want to on/off Led using timers i have configured GPIO pins but i am not getting how to use timers plz anyone can u share sample code of timer or plz give me some suggestions

 

 

 

Thank you

  • In reply to mahesh:

    Hello, mahesh.

    I confirmed the 500ms-blinking by comment-outing following lines of the original RZ_A1H_Tutorial_RSK.
    main.c(178): flashled();
    main.c(182): static_test();
    main.c(215): OSTM0.OSTMnCMP = (uint32_t)(P0_CLOCK_FREQUENCY_kHz * (g_adc_result + 1));
  • In reply to hagiryo:

    hello sir
    i tried the following sir but still its not working i'm using RZ_A1H_Tutorial_RSK in that i have modified main.c


    int_t main(void)
    {
    char strdata[32] = "";
    uint8_t * pmptr = &g_rgb888_logo[0];

    R_RIIC_rza1h_rsk_init();

    /* Initialise SPI */
    R_SPI_Init();

    /* Initialise the PMod Colour LCD display */
    // R_LCD_Init();

    /* Initialise direct connected LED */
    R_LED_Init();

    /* Initialise board switches (SW1,SW2,SW3) */
    init_switches();

    /* Display 'Renesas' Logo at bottom of screen */
    // display_image (pmptr, 128, 24, 0, 104);
    // display_on();

    //display_lcd(0, (uint8_t *)" RSK+RZA1H");
    //display_lcd(2, (uint8_t *)" Tutorial Sample");

    // flashled();

    // clear_display_area();

    static_test();

    //clear_display_area();

    // display_lcd(4, (uint8_t *)" Use RV1 to set delay");
    //display_lcd(5, (uint8_t *)" using timer OSTM ");
    //display_lcd(6, (uint8_t *)" when flashing LEDs");

    /* Initialise OS timer (channel 0) */
    R_OSTM_Init(DEVDRV_CH_0, OSTM_MODE_INTERVAL, 500);

    /* Start OS timer (channel 0) */
    R_OSTM_Open(DEVDRV_CH_0);

    /* Initialise Analogue input (Potentiometer) on board */
    //R_ADC_Open();

    while(1)
    {
    // R_ADC_Read();

    // sprintf(strdata," Flash Delay %d ms ",(uint16_t)g_adc_result);
    // display_lcd(8, (uint8_t *)strdata);

    //sprintf(strdata," RV1 position %3d %% ",(int16_t)((g_adc_result/1023.0)*100.0));
    //display_lcd(10, (uint8_t *)strdata);

    /* Set the minimum flash rate if the ADC value is less than the minimum */
    if (g_adc_result < MIN_FLASH_RATE)
    {
    g_adc_result = MIN_FLASH_RATE;
    }

    OSTM0.OSTMnCMP = (uint32_t)(P0_CLOCK_FREQUENCY_kHz * (g_adc_result + 1));

    }
    return (0);
    }

    sir i have commented display settings and functions because i am not using it sir please help me with this

    Thanks
  • In reply to mahesh:

    Hello, mahesh.

    Could you check the project I confirmed?

    RZ_A1H_Tutorial_RSK.zip

    The display module this program uses PMOD LCD display bundled in the board.

    Display driver does only write, does not read anything from PMOD LCD display. Therefore even if we call LCD driver without connecting LCD display, it will not cause any problems.

  • In reply to hagiryo:

    Hello sir,
    Thank you i will check now and let you know as soon as possible and display i will connect to display connector pmod1


    Thank you,
  • In reply to mahesh:

    Dear Sir,

    i tried the above sample code which u have provided but what it is happening is it will stuck in while loop while calling
    r_riic_init_ch3(); in R_RIIC_rza1h_rsk_init(); function


    and it will get here and it will in while loop and will not come out
    /* Is the bus free? */
    while (0x00008 == (priic->RIICnCR2.UINT32 & 0x0008))
    {
    __asm__("nop");
    }

    how to sovle this issue plz help
    Thanks
  • In reply to mahesh:

    Dear sir ,
    i'm getting same issue even when i call R_LCD_Init(); and i tried commenting all display section and tried but not able to flash LED p7_1 for certain ms

    int main(void){
    char strdata[32] = "";
    uint8_t * pmptr = &g_rgb888_logo[0];

    // R_RIIC_rza1h_rsk_init();

    /* Initialise SPI */
    //R_SPI_Init();

    /* Initialise the PMod Colour LCD display */
    //R_LCD_Init();

    /* Initialise direct connected LED */
    R_LED_Init();

    /* Initialise board switches (SW1,SW2,SW3) */
    init_switches();

    /* Display 'Renesas' Logo at bottom of screen */
    //display_image (pmptr, 128, 24, 0, 104);
    //display_on();

    //display_lcd(0, (uint8_t *)" RSK+RZA1H");
    //display_lcd(2, (uint8_t *)" Tutorial Sample");

    // flashled();

    //clear_display_area();

    // static_test();

    //clear_display_area();

    //display_lcd(4, (uint8_t *)" Use RV1 to set delay");
    //display_lcd(5, (uint8_t *)" using timer OSTM ");
    // display_lcd(6, (uint8_t *)" when flashing LEDs");

    /* Initialise OS timer (channel 0) */
    R_OSTM_Init(DEVDRV_CH_0, OSTM_MODE_INTERVAL, 500);

    /* Start OS timer (channel 0) */
    R_OSTM_Open(DEVDRV_CH_0);

    /* Initialise Analogue input (Potentiometer) on board */
    R_ADC_Open();

    while(1)
    {
    R_ADC_Read();

    // sprintf(strdata," Flash Delay %d ms ",(uint16_t)g_adc_result);
    //display_lcd(8, (uint8_t *)strdata);

    // sprintf(strdata," RV1 position %3d %% ",(int16_t)((g_adc_result/1023.0)*100.0));
    // display_lcd(10, (uint8_t *)strdata);

    /* Set the minimum flash rate if the ADC value is less than the minimum */
    if (g_adc_result < MIN_FLASH_RATE)
    {
    g_adc_result = MIN_FLASH_RATE;
    }

    //OSTM0.OSTMnCMP = (uint32_t)(P0_CLOCK_FREQUENCY_kHz * (g_adc_result + 1));

    }
    return (0);
    }
  • In reply to mahesh:

    Dear Sir,

    i have tried de-commenting this

    //OSTM0.OSTMnCMP = (uint32_t)(P0_CLOCK_FREQUENCY_kHz * (g_adc_result + 1));
    but not coming
  • In reply to mahesh:

    I confirmed LED blinking with 500ms interval by compiling your main() function.

    Is your LED0(P7_1) not lit?

    Note that please do not press reset button of board or debugger before running project.
    This sample program is downloaded to Internal RAM.
    By resetting the MPU or the board, another program stored in the another memory will run.

    The following line specifies the blinking interval by AD input level that is able to be changed by RV1.
    ======================
    OSTM0.OSTMnCMP = (uint32_t)(P0_CLOCK_FREQUENCY_kHz * (g_adc_result + 1));
    ======================