renasas microcontroller r8c27

Discussion in 'Programmer's Corner' started by pramodpa3, Apr 24, 2013.

  1. pramodpa3

    Thread Starter New Member

    Apr 24, 2013
    9
    0
    me working on renasas microcontroller r8c/27 i need an program for an uart using tool as high performance embedded work shop i did all but not able to run my job is in danger plz help me /***********************************************************************/
    /* */
    /* FILE :uartset.c */
    /* DATE :Fri, Apr 19, 2013 */
    /* DESCRIPTION :main program file. */
    /* CPU GROUP :27 */
    /* */
    /* This file is generated by Renesas Project Generator (Ver.4.15). */
    /* */
    /***********************************************************************/
    #include "sfr_r827.h"


    void main(void)
    {
    unsigned char ucu1_in;
    }
    void uart_init(void)
    {
    pinsr1=0x05;
    pmr=0x36;
    u1brg=129;
    u1mr=0x05;
    u1c0=0x00;
    ucu1_in ='yes';
    u1tb=ucu1_in;
    u1tb=u1rb;
    u1rb='yes';
    u1c1=0x05;
    }
    void text_write (char * HITECH)
    {
    int i=0;
    char a[]="HI-TECH SOLUTIO\r\n\0";
    /* This loop reads in the text string and puts it in the UART 0 transmit buffer */
    for (i=0; a!='\0'; i++)
    {
    while(ti_u1c1 == 0);
    u1tb = a;
    }
    }
    plz help me
     
    Last edited: Apr 24, 2013
  2. pramodpa3

    Thread Starter New Member

    Apr 24, 2013
    9
    0
  3. pramodpa3

    Thread Starter New Member

    Apr 24, 2013
    9
    0
    also send me i2c and steeper motor
     
  4. takao21203

    Distinguished Member

    Apr 28, 2012
    3,577
    463
    Yooooooooooo.

    How did you get the job in the first place?
    When you have difficulties with standard pheripherals?

    You'll have your mail address snipped quite soon it is not working that way, and it is a security risk as well.

    I2C I could give you PIC C code for software I2C.
    I wrote it solemny using the DS1307 datasheet and nothing else.
    No logic analyzer.

    Datasheets only have to be examined carefully, read as many times as required, and followed step by step with all details.
     
  5. MrChips

    Moderator

    Oct 2, 2009
    12,441
    3,361
    What does the main( ) program do?

    When and where is uart_init( ) called?

    When and where is text_write( ) called?

    What does ucu1_in ='yes' do?

    I think you need to find a tutorial on the essentials of C programming.
     
  6. pramodpa3

    Thread Starter New Member

    Apr 24, 2013
    9
    0
    hai ,
    thanks alot but sme wat my prblms so i got
    it
    ucu1_in is an temperary buffer.plz prvide an code
     
  7. pramodpa3

    Thread Starter New Member

    Apr 24, 2013
    9
    0
    send the mail id i will send u the details oof all
     
  8. pramodpa3

    Thread Starter New Member

    Apr 24, 2013
    9
    0
    ok send me fresher so help me
     
  9. pramodpa3

    Thread Starter New Member

    Apr 24, 2013
    9
    0
    plz send me an uart code for r8c/27 renasas controller
     
  10. pramodpa3

    Thread Starter New Member

    Apr 24, 2013
    9
    0
    /**********************************************************************************
    FILE NAME main.c
    DESCRIPTION: R8C/27 to a terminal program
    via UART1 and RS232. UART1 configuration is:
    19200 baud, 8-bit data, 1 stop bit, no parity, no flow control.

    Incrementing data (0 to 9) is sent to the terminal window.
    To stop receiving data, press z on the keyboard. To resume, press any key.
    While data is transmitting LED1 is on and LED2 is off. When transmission
    is stopped by pressing "z" LED2 turns on and LED1 turns off


    ***************************************************/

    #include "rskr8c27def.h"
    #include "sfr_r827.h"
    #include "main.h"
    #include "_LCD_R8C.c"
    /* ************************* Global variables ********************************/

    unsigned char ucU1_in;

    /* String constants used for screen output */
    char cmd_clr_scr[] = {27,'[','2','J',0};
    char cmd_cur_home[] = {27,'[','H',0};


    void main(void) {

    unsigned char ucCount;
    unsigned short ucConvert;
    unsigned short usDelay;

    uart_init();
    lcd_init();
    lcd_clear();
    lcd_delay();
    lcd_printxy(1,5,"MAJESTIC ");
    lcd_delay();
    lcd_delay();
    lcd_printxy(2,4,"AUTOMATION");
    lcd_delay();
    /* Text to be displayed at the beginning of the program output to the terminal
    window (\r\n = carriage return & linefeed) */

    text_write(cmd_clr_scr);
    text_write(cmd_cur_home);
    text_write("MAPL EMBEDDED SOLUTIONS \r\n");

    text_write("Press z to stop, any key to continue. \r\n");

    /************** MAIN PROGRAM LOOP ***********************/
    for(;;){

    /* setup program loop to count from 0 to 9, stop when "z" is received */

    while (ucU1_in != 'z'){
    /* send carrige return and line feed*/
    text_write("\r\n");
    // LED2 = LED_OFF;
    //LED1 = LED_ON;

    for (ucCount=0;(ucCount<=9)&&(ucU1_in!='z');ucCount ++){
    /* convert count data to ASCII */
    ucConvert = ucCount + 0x30;
    while(ti_u1c1 == 0);
    u1tb = ucConvert;
    for (usDelay=0xffff; usDelay>0; usDelay--);
    }
    }
    /* Do nothing while stopped (after "z" is pressed) */
    _asm("NOP");
    }
    }


    /*****************************************************************************
    Name: UART1 Receive Interrupt Routine
    Parameters: none
    Returns: none
    Description: Interrupt routine for UART1 receive
    Reads character received from keyboard and stores U1_in variable
    *****************************************************************************/
    void U1rec_ISR(void){

    ucU1_in = (char) u1rb;
    if (ucU1_in == 'z'){
    while(ti_u1c1 == 0);
    u1tb = 'z';
    // LED2 = LED_ON;
    // LED1 = LED_OFF;
    }
    }

    void uart_init(void){

    pinsr1 = 0x05;


    pmr = 0x36;



    /* set UART1 bit rate generator */
    u1brg = 129;//(unsigned char)(((f1_CLK_SPEED/16)/BAUD_RATE)-1);
    /*
    bit rate can be calculated by:
    bit rate = ((BRG count source / 16)/baud rate) - 1
    ** the value of BCLK does not affect BRG count source
    */

    u1mr = 0x05;


    u1c0 = 0x00;

    u1tb = u1rb;
    u1tb = 0;

    DISABLE_IRQ
    s1ric = 0x04;
    ENABLE_IRQ

    u1c1 = 0x05;
    }


    void text_write (char * msg_string)
    {
    char i;
    /* This loop reads in the text string and puts it in the UART 0 transmit buffer */
    for (i=0; msg_string; i++){
    while(ti_u1c1 == 0);
    u1tb = msg_string;
    }
    }
    this was an sample prgm
     
  11. pramodpa3

    Thread Starter New Member

    Apr 24, 2013
    9
    0
    reply i neededee an code fr uart
     
Loading...