setting digital I/O, pic16f690, using ccs pcm

Discussion in 'Embedded Systems and Microcontrollers' started by Blasterdito, Jul 20, 2008.

  1. Blasterdito

    Thread Starter New Member

    Jul 9, 2008
    5
    0
    Huy guys (and girls)

    I have two questions

    1.
    I'm trying to make pic16f690 recive bytes on pin 19 RAO and send bytes on pin 10 RB7,
    I have red that I need to make pins digital and also define them as in or out pins, If I'm not mistaking I need to put "set_trisx(...) somewhere?

    2. How do I set the internal oscillator
    I'm thinking if this is correct, and does this mean that I don't need any external xrstal?

    Code ( (Unknown Language)):
    1.  
    2. #FUSE INTRC and
    3. #Delay (clock=...)  
    4.  
    but I don't know if it's correct.

    Here is my code

    Code ( (Unknown Language)):
    1. #include <16F690.h>
    2. #fuses NOWDT,HS,NOPUT,NOPROTECT
    3. #use delay(clock=8000000)  
    4. #use rs232(baud=2400,parity=N,xmit=PIN_B7,rcv=PIN_B5,bits=9)
    5. void clockwait(void);
    6. void main()
    7. {
    8.    unsigned char byt;   // Holds each byte received
    9.    unsigned char t;     // Variable t declaration
    10.    setup_counters(RTCC_INTERNAL,RTCC_DIV_1);
    11.    while(1)         // Loop forever...
    12.    {
    13.       byt=0;         // Starting a new data frame
    14.       clockwait();      // Ignore start bit
    15.       for(t=0;t<8;t++)      // Grab eight bits of data...
    16.       {
    17.          clockwait();
    18.             byt|=input(PIN_A0)<<t;
    19.       }
    20.       clockwait();         // Ignore parity bit
    21.       clockwait();      // Ignore stop bit
    22.       putc(byt);         // Send byte to the transmitter
    23.    }            // ... rinse and repeat :)
    24. }
    25. void clockwait(void)
    26. {
    27.    // Waits for the next clock cycle...
    28.       while(!input(PIN_A1));   // Wait for clock to go HI
    29.       while(input(PIN_A1));   // Wait for clock to go LO
    30. }

    I've bin trying to figure this out for 3 days now, any help would be extremly appriciated.

    :confused:

    Regards
     
Loading...