Jump to content
43oh

chandra

Members
  • Content Count

    1
  • Joined

  • Last visited

Reputation Activity

  1. Like
    chandra reacted to SirZusa in How to initialize MSP430F5510 correctly?   
    Hi,
     
    i got RobG's development board some days ago and started playing with it.
    Soon i have discovered some points that i don't understand... I started with RobG's UART-example and modified it a little bit.
     
    The changes that i made so far:
    1. It now runs at 24 MHz (clocked by XT2)
    2. stripped some unneccessary NOP's (no operation)
    3. inlined some functions for initialization and handling
     

    /*** USB-Includes ***/ #include "USB_config/descriptors.h" #include "USB_API/types.h" #include "USB_API/device.h" #include "USB_API/usb.h" #include "USB_API/UsbCdc.h" #include "usbConstructs.h" /*** HAL-Includes ***/ #include "F5510/HAL_UCS.h" #include "F5510/HAL_PMM.h" /*** USB-Variables ***/ // Flag set by event handler to indicate data has been received into USB buffer volatile BYTE bCDCDataReceived_event = false; #define BUFFER_SIZE 32 char dataBuffer[bUFFER_SIZE] = ""; /////////////////////////////////////////////////////////// void main(void) { // Stop watchdog timer WDTCTL = WDTPW + WDTHOLD; // initialize all ports and set them to output-direction P1OUT = 0x00; P1DIR = 0xFF; P2OUT = 0x00; P2DIR = 0xFF; P3OUT = 0x00; P3DIR = 0xFF; P4OUT = 0x00; P4DIR = 0xFF; P5OUT = 0x00; P5DIR = 0xFF; P6OUT = 0x00; P6DIR = 0xFF; PJOUT = 0x00; PJDIR = 0xFF; // Higher V_Core needed for Coreclock at 24 MHz SetVCore(PMMCOREV_3); // Initialization of clock module // enable XT2 pins P5SEL |= 0x0C; // use REFO for FLL and ACLK // ??? UCSCTL3 = (UCSCTL3 & ~(SELREF_7)) | (SELREF__REFOCLK); UCSCTL4 = (UCSCTL4 & ~(SELA_7)) | (SELA__REFOCLK); // MCLK will be driven by the FLL (not by XT2), referenced to the REFO // Start the FLL, at the freq indicated by the config // ??? Init_FLL_Settle(USB_MCLK_FREQ / 1000, USB_MCLK_FREQ / 98361); // Start the "USB crystal" - constant USB_MCLK_FREQ XT2_Start(XT2DRIVE_0); // Initialization of USB module // Init USB USB_init(); // Enable USB event handling routines USB_setEnabledEvents(kUSB_allUsbEvents); // See if we're already attached physically to USB, and if so, connect to it // Normally applications don't invoke the event handlers, but this is an exception. if (USB_connectionInfo() & kUSB_vbusPresent) { if (USB_enable() == kUSB_succeed) { USB_reset(); USB_connect(); } } /////////////////////////////////////////////////////////// // enable interrupts __bis_SR_register(GIE); // MCLK = XT2 SELECT_MCLK(SELM__XT2CLK); // no divisor - full speed MCLK_DIV(1); // main loop while (1) { // generate a clock on P1.0 to measure it toggle(P1OUT, BIT0); // ST_ENUM_ACTIVE if ((USBPWRCTL & USBBGVBV) && (USBCNF & PUR_EN) && (bEnumerationStatus == ENUMERATION_COMPLETE) && (!(bFunctionSuspended == TRUE))) { while (bCDCDataReceived_event) { // Clear flag early -- just in case execution breaks below because of an error bCDCDataReceived_event = false; // Count has the number of bytes received into dataBuffer WORD count = cdcReceiveDataInBuffer((BYTE*) dataBuffer, BUFFER_SIZE, CDC0_INTFNUM); // process incomming data WORD c = 0; while (c < count) { DataHandling(dataBuffer[c]); c++; } } } } } /* * ======== UNMI_ISR ======== */ #pragma vector = UNMI_VECTOR __interrupt void UNMI_ISR(void) { switch (__even_in_range(SYSUNIV, SYSUNIV_BUSIFG)) { case SYSUNIV_NONE: // __no_operation(); break; case SYSUNIV_NMIIFG: // __no_operation(); break; case SYSUNIV_OFIFG: // clear OSC flags UCSCTL7 &= ~(DCOFFG + XT1LFOFFG + XT2OFFG); SFRIFG1 &= ~OFIFG; //Clear OFIFG fault flag break; case SYSUNIV_ACCVIFG: // __no_operation(); break; case SYSUNIV_BUSIFG: // clear bus error flag SYSBERRIV = 0; // disable USB_disable(); break; } }
     
    USB CDC is up and running, if the values for the FLL are wrong Windows won't detect the proper device.
    If everything is fine the speed i tested got over 4.000.000 baud without problems.
     
    So the questions that i have after the first hours working with the MSP430F5510 are:
    - Are there some Interrupt-Routines for handling incomming data? The actual method is really inefficient (Polling in an endless loop)
    - How does the FLL work? How to set proper parameters? Wrong values lead to a lock because it can't settle.
    - What is REF0? Why use it for FLL and ACLK instead of XT2?
     
    Maybe some of you can answer or help me out ... still a lot of things to learn the next days
×
×
  • Create New...