Pic16c745


Closed Thread
Results 1 to 5 of 5

Thread: Pic16c745

  1. #1
    Join Date
    Sep 2010
    Posts
    2

    Unhappy Pic16c745

    Hi does anyone here knows how to light up the LED using MPLAB software but the code is C+.below is my code i try but i am stuck ,i think i am wrong somewhere as i am very weak in programming so i need guardian it will be greatly appreciated if you can help me.I have to put in the code into the microchip to make the LED light up .I also ask around do i need to use timer 2 interrupt to write in the while loop?i not sure how to do that.




    #include <htc.h>
    //#include "delay.h"
    __CONFIG(WDTDIS & PWRTDIS & UNPROTECT & H4);


    void init(void)
    {
    PORTB = 0x02;
    TRISB = 0x02;
    }
    void InitUSART(void)
    {
    TXSTA = 0x22;
    RCSTA = 0x90;
    SPBRG = 0x9b;
    }

    void enter(void)
    {
    while(!TRMT);
    TXREG = 0x0d;
    }

    void tx_start(void)
    {
    while(!TRMT);
    TXREG = 0x1a;
    }

    void send_msg(const char *str)
    {
    char ps;
    ps = *str;
    while(ps>0)
    {
    str++;
    if (ps== 0) break;
    while(!TRMT);
    TXREG = ps ;
    ps = *str;
    }

    }


    void main(void)
    {
    init();
    InitUSART();

    while (1)
    {

    if(RB1 == 0)
    {
    RB2 = 0x1;
    RB3 = 0x04;



    RB2 = 0x0;

    }
    else if(RB1=1)
    {
    RB2 = 0x0;
    RB3 = 0x0;
    }
    }
    }

  2. #2
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    There are a ton of people that are on this forum to escape having to think about C. You might try a C forum, and they might be more help.We just have a lot of examples in PicBasic.
    http://www.scalerobotics.com

  3. #3
    Join Date
    Sep 2010
    Posts
    2


    Did you find this post helpful? Yes | No

    Cool Pic16c745

    scalerobotics I don't think you should say escape .Programming is not like a one day thing which you can possibly know it well.People just need guardian and help .I did some research too,No one is perfect ,if you so good at it, is that any useful links for that? i admit i am programming nerd. Please mind your words.thank you.

  4. #4
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by cuitesun View Post
    . Please mind your words.thank you.
    Hi, Cuitesun

    The problem is NOT you being a nerd or else or not ...

    asking that here is same as ask it the " Merlion " or Jurong Falls birds ( ahaaaa .... )

    Their answers will be something " life is water " or "Lucy in the sky " ( the songs ).

    Shorly told, nobody or so here uses ( or wants to use ...) C, even C+ ...

    I just doubt any Port pin will take 4 as a value, for anything else the bug might be in your config line ... ( never seen "H4" as a parameter nor ... as it is 16 bits coded )

    Now ....
    You would have much more answers aboard the Microchip forum ... if you use a Microchip compiler : is that a decent answer ???

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  5. #5
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    Sorry cuitesun, I did not mean to offend anyone. Just trying to keep our PicBasic forum on topic. We could start to (try) to discus C, C++, Fortran, Java. And I am sure some of our members are well versed on other topics as well. But that really was not what this site is intended for. That is why we suggest going to a site whose members specialize in the subject of your inquiry.
    http://www.scalerobotics.com

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts