Jump to content
43oh

[IPB Update .4] Editor check


Recommended Posts

Quote works... it wont display the bbcode. It will indent it.

 

attachicon.gifsmiley1.jpg

 

Image inline test.

 

 

A little strange not seeing the "quote" tags and such rendered inline.

Might make multi-quotes a fun endeavor.

Yep, nothing to separate one quote from the other when editing or replying except some blank, whitespace.

 

Note to self- use full editor and "preview" before posting.

Link to post
Share on other sites
/*
 * main.c
 */

#include <msp430.h>
#include <stdint.h>

const unsigned long MCLK_HZ = 16000000;          // SMCLK frequency in hertz
const unsigned BPS = 2400;                       // ASYNC serial baud rate

void printc(const char c) {
    while(!(IFG2 & UCA0TXIFG));                  // wait for TX buffer to be empty
    UCA0TXBUF = c;
}

void print(const char *s) {
    while(*s) printc(*s++);
}

void printx(const uint8_t c) {
    static char hex_table[] = "0123456789ABCDEF";

    printc(hex_table[(c & 0xF0) >> 4]); printc(hex_table[c & 0x0F]);
}

int main(void)
{
    const unsigned long baud_rate_20_bits = (MCLK_HZ + (BPS >> 1)) / BPS; // Bit rate divisor

    WDTCTL = WDTPW + WDTHOLD;                       // No watchdog reset
                                                    //
    DCOCTL = 0;                                     // Run at 16 MHz
    BCSCTL1 = CALBC1_16MHZ;                         //
    DCOCTL  = CALDCO_16MHZ;                         //

    __delay_cycles(16000000/100);                   // slight delay

    // Configure P1.1 and P1.2 as uart controlled pins
    P1DIR  = ~(BIT2 | BIT1);                        // Revert to default to GPIO input
    P1SEL = BIT1 | BIT2;                            // P1.1=RXD, P1.2=TXD
    P1SEL2 = BIT1 | BIT2;                           // P1.1=RXD, P1.2=TXD

    // Configure USCI UART for 2400
    UCA0CTL1 = UCSWRST;                             // Hold USCI in reset to allow configuration
    UCA0CTL0 = 0;                                   // No parity, LSB first, 8 bits, one stop bit, UART (async)
    UCA0BR1 = (baud_rate_20_bits >> 12) & 0xFF;     // High byte of whole divisor
    UCA0BR0 = (baud_rate_20_bits >> 4) & 0xFF;      // Low byte of whole divisor
    UCA0MCTL = ((baud_rate_20_bits << 4) & 0xF0) | UCOS16; // Fractional divisor, over sampling mode
    UCA0CTL1 = UCSSEL_2;                            // Use SMCLK for bit rate generator, then release reset

    print("\r\nRunning\r\n");

    print("Print ascii characters:\r\n");
    {
        uint8_t c;

        for(c = ' '; c <= '~'; ++c) {
            printc(c);
            if ( c == ' '+64 ) {
                print("\r\n");
            }
        }
    }
    print("\r\n");

    return 0;
}

 

Seems like it is better. I was able to put code in the post. Then edit it, and added this comment. So I give it a tentative thumbs up.  :) Still would like to see a gist embed ...

 

-rick

Link to post
Share on other sites

 

/*
 * main.c
 */

#include <msp430.h>
#include <stdint.h>

const unsigned long MCLK_HZ = 16000000;          // SMCLK frequency in hertz
const unsigned BPS = 2400;                       // ASYNC serial baud rate

void printc(const char c) {
    while(!(IFG2 & UCA0TXIFG));                  // wait for TX buffer to be empty
    UCA0TXBUF = c;
}

void print(const char *s) {
    while(*s) printc(*s++);
}

void printx(const uint8_t c) {
    static char hex_table[] = "0123456789ABCDEF";

    printc(hex_table[(c & 0xF0) >> 4]); printc(hex_table[c & 0x0F]);
}

int main(void)
{
    const unsigned long baud_rate_20_bits = (MCLK_HZ + (BPS >> 1)) / BPS; // Bit rate divisor

    WDTCTL = WDTPW + WDTHOLD;                       // No watchdog reset
                                                    //
    DCOCTL = 0;                                     // Run at 16 MHz
    BCSCTL1 = CALBC1_16MHZ;                         //
    DCOCTL  = CALDCO_16MHZ;                         //

    __delay_cycles(16000000/100);                   // slight delay

    // Configure P1.1 and P1.2 as uart controlled pins
    P1DIR  = ~(BIT2 | BIT1);                        // Revert to default to GPIO input
    P1SEL = BIT1 | BIT2;                            // P1.1=RXD, P1.2=TXD
    P1SEL2 = BIT1 | BIT2;                           // P1.1=RXD, P1.2=TXD

    // Configure USCI UART for 2400
    UCA0CTL1 = UCSWRST;                             // Hold USCI in reset to allow configuration
    UCA0CTL0 = 0;                                   // No parity, LSB first, 8 bits, one stop bit, UART (async)
    UCA0BR1 = (baud_rate_20_bits >> 12) & 0xFF;     // High byte of whole divisor
    UCA0BR0 = (baud_rate_20_bits >> 4) & 0xFF;      // Low byte of whole divisor
    UCA0MCTL = ((baud_rate_20_bits << 4) & 0xF0) | UCOS16; // Fractional divisor, over sampling mode
    UCA0CTL1 = UCSSEL_2;                            // Use SMCLK for bit rate generator, then release reset

    print("\r\nRunning\r\n");

    print("Print ascii characters:\r\n");
    {
        uint8_t c;

        for(c = ' '; c <= '~'; ++c) {
            printc(c);
            if ( c == ' '+64 ) {
                print("\r\n");
            }
        }
    }
    print("\r\n");

    return 0;
}

 

Seems like it is better. I was able to put code in the post. Then edit it, and added this comment. So I give it a tentative thumbs up.   :smile: Still would like to see a gist embed ...

 

-rick

 

Let's see if I can quote the code?

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...