Other Parts Discussed in Thread: MSPWARE
Tool/software: Code Composer Studio
Hello texas-team,
over the last couple of months I kept on seeing weird stuff happening in my MSP430 devices once enabling the USB via the code-line:
USB_setup(TRUE,TRUE);
in there comes some interesting behaviour:
uint8_t USB_setup(uint8_t connectEnable, uint8_t eventsEnable) { uint8_t status; status = USB_init(); if (eventsEnable) { USB_setEnabledEvents(USB_ALL_USB_EVENTS); } if (connectEnable) { if (USB_getConnectionInformation() & USB_VBUS_PRESENT){ if (USB_enable() == USB_SUCCEED){ USB_reset(); USB_connect(); } } } return (status); }
The USB_init() contains the following lines, already a bit altered by me, since the automatic chrytsal detectino wouldnt work in my case:
USB_XT2Freq = USB_determineXT2Freq(); USB_XT2Freq = 24; USB_XT2PLL = USB_lookUpPll(USB_XT2Freq); uint16_t MCLKFreq = USB_determineFreq();
now the determine XT2Freq really break my code since it is using the TimerA1 which I do use in some other mannor already:
in the folder: USB_API/USB_common/usb.c
// Timer A1 Settings - Used for XT2 Frequency Auto Detect #define TIMER_CTL TA1CTL #define TIMER_CTL_SETTINGS TASSEL_2 + MC_2 + CNTL_0 #define TIMER_CTL_CLR TACLR #define TIMER_CCTL TA1CCTL2 #define TIMER_CCTL_SETTINGS CM_1 + CCIS_1+ CAP #define TIMER_CCTL_IFG CCIFG #define TIMER_CCTL_CM CM_1 #define TIMER_CCR TA1R
there it states what timer is used for those purposes, sadly I havent realized earlier.
Just wanted to know, hwo am I supposed to work with that?
My current workaround would be to rewrite the USB_code, so that no automatic chrystal determination is needed, since I do know my chrystals very well.
Then I will use the timer only for my purposes.
The other thing I could do is initialize the USB-code right at the beginning ( I do it rather at the end and furthermore I can toggle USB on and off in my code in different locations, so that will of course trigger the USB again and destroy my peripherals again)
and after the USB initialization I will init all my ADCs and Timer etc.
What would you suggest, how does Texas use their USB.
In all the examples I have never seen the usage of TimerA1 after the USB_init.
Thanks for reading,
best wishes.