EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Topics / Working code of the pic32mx440f256l

Working code of the pic32mx440f256l

|

Microcontroller › PIC › Working code of the pic32mx440f256l

  • This topic has 1 reply, 2 voices, and was last updated 12 years ago by AJISH ALFRED.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • March 7, 2014 at 1:20 pm #2927
    nilesh
    Participant

    Hi,

     

              This is the working code of the pic32MX440f256L.

     

     

     

    #define FCY     6000000UL
    #include <plib.h>
     
     
    void Tx2Ch(char Ch)
    {
        while(U2STAbits.UTXBF);                     // wait while Tx buffer full
        U2TXREG = Ch;
    }
     
    void Tx2Str(char *Str)
    {
        while(*Str){
            Tx2Ch(*Str++);
        }
    }
     void UARTInit()
     {
      TRISFbits.TRISF4 = 1;                               // U2RX pin configured as a input.
      TRISFbits.TRISF5 = 0;                               // U2TX pin configured as a output.
      U2BRG=194;                                             //for 19200
      //  U2MODEbits.ON = 1;  // stop in idel mode bit
      U2MODEbits.USIDL = 0;  // stop in idel mode bit
      U2MODEbits.IREN = 0; // encoder and decoder enable bit
      U2MODEbits.RTSMD = 0; // mode selection for RTS
      U2MODEbits.UEN = 2;  // UART enabled bit
      U2MODEbits.WAKE = 0; // wake up on start bit detect during sleep mode enable bit
      U2MODEbits.LPBACK = 0; // UART loop back mode
      U2MODEbits.ABAUD = 0; // auto boud enable bit
      U2MODEbits.RXINV = 0; // receive polarity inversion
      U2MODEbits.BRGH = 0; // high baud rate enable bit
      U2MODEbits.PDSEL = 0; // parity and data selection bit
      U2MODEbits.STSEL = 0; // stop bit selection bit
      U2STAbits.UTXISEL0 = 0; // transmission interrupt mode selection bits
      U2STAbits.UTXISEL1 = 1;
      U2STAbits.UTXINV = 0; // transmit polarity inversion bit
      U2STAbits.UTXBRK = 0; // transmit break bit
      U2STAbits.URXISEL = 0; // receiver interrupt mode selection bits
      U2STAbits.ADDEN = 0; // address character detect bit
      U2STAbits.UTXEN = 1;    // transmit enable bit
      //


    //
       U2STAbits.URXEN = 1;    // receivert enable bit
       IFS1bits.U2RXIF = 0; // Clear Flag
       IPC8bits.U2IP = 4; // Set Priority
       IPC8bits.U2IS = 1; // Set Sub-Priority
       IEC1bits.U2RXIE = 1; // Enable Interrupt
     
    //  IFS1bits.U2RXIF= 0;
      IFS1bits.U2TXIF= 0;
      IEC1bits.U2TXIE = 0;                                // U2TX interrupt disabled.
      //IEC1bits.U2RXIE = 1;                                // U2RX interrupt enabled.
      IFS1bits.U2EIF=0; //Clears error interrupt flag
      U2MODEbits.UARTEN = 1; // UART enable bit
    }
     
     void __ISR(_UART_2_VECTOR, IPL4SOFT)UART2VECTORHandler (void)
    {
         IFS1bits.U2RXIF=0;
         char u2_rx;
         u2_rx = U2RXREG;
         U2TXREG =  u2_rx;
     
    }
     
    void main(void)
    {
     //Controller working on 60Mhz
     
       UARTInit();
       DelayMs(500);
         while(1)
        {
     
            Tx2Str(“SAMPLE“);
             DelayMs(500);
        }

    }

    March 19, 2014 at 1:50 pm #11339
    AJISH ALFRED
    Participant

    what does this code do?

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • Voltage comparator circuit verification April 10, 2026
  • Some opamp advice please April 10, 2026
  • Help with a coffee machine circuitboard April 10, 2026
  • Bot checks April 10, 2026
  • Assistance locating a 'trail' camera gadget, please ? April 10, 2026

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2026 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise