msp430

Different results between a 16-bit int machine and a 32-bit int machine in a subtraction

大憨熊 提交于 2019-12-22 18:10:04
问题 When the code below is run against a 16-bit integer machine like MSP430 micro controller, s32 yields 65446 #include <stdint.h> uint16_t u16c; int32_t s32; int main() { u16c = 100U; s32 = 10 - u16c; } My understanding is that 10 - u16c gets implicit type promotion to unsigned int. Mathematically 10 - u16c equals to -90. But how is it possible to represent a negative number as an unsigned int? When -90 gets promoted to unsigned int, does it mean that the sign of a number is ignored? Lets

Different results between a 16-bit int machine and a 32-bit int machine in a subtraction

心已入冬 提交于 2019-12-22 18:09:56
问题 When the code below is run against a 16-bit integer machine like MSP430 micro controller, s32 yields 65446 #include <stdint.h> uint16_t u16c; int32_t s32; int main() { u16c = 100U; s32 = 10 - u16c; } My understanding is that 10 - u16c gets implicit type promotion to unsigned int. Mathematically 10 - u16c equals to -90. But how is it possible to represent a negative number as an unsigned int? When -90 gets promoted to unsigned int, does it mean that the sign of a number is ignored? Lets

MSP430G2553 Timer Intervals [closed]

↘锁芯ラ 提交于 2019-12-20 05:38:11
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 3 years ago . After reading the text about five times and googling I've decided to reach out for help. I'm currently in the process of using Timer_A interrupt to turn on/off two LEDS in intervals of 1 second/10 seconds/1 minute one at a time. The default program will turn on/off the LEDS every second but I

Embedded C: Registers Access

我怕爱的太早我们不能终老 提交于 2019-12-13 13:16:07
问题 Suppose we want to write at address say 0xc000 , we can define a macro in C as: #define LCDCW1_ADDR 0xc000 #define READ_LCDCW1() (*(volatile uint32_t *)LCDCW1_ADDR) #define WRITE_LCDCW1(val) ((*(volatile uint32_t *)LCDCW1_ADDR) = (val)) My question is that when using any micro-controller, consider an example MSP430, P1OUT register address is 0x0021. But when we use P1OUT=0xFFFF; // it assigns P1OUT a value 0xFFFF. My question is how does it write to that address e.g. in this case 0x0021. The

Can I use UART on MSP-EXP430F5529LP from Energia in order to communicate on pins p3.3 and p3.4 (rx and tx respectively)?

大兔子大兔子 提交于 2019-12-13 06:14:55
问题 Can I use UART on MSP-EXP430F5529LP from Energia in order to communicate on pins p3.3 and p3.4 (rx and tx respectively)? I already use UART in order to communicate with my PC via USB. To do so, I use Serial.println() and such. Now that one UART is taken, how do I configure and use second UART to go to these pins? Or would it be better to rewire my Bluetooth chip (BlueGiga wt32) to some other pins? Configuration aside, Serial does not seem to allow for multiple UARTs. How does it know which

what do these instructions do

為{幸葍}努か 提交于 2019-12-12 22:05:25
问题 I am working on a simulator for the msp430 instruction set. gnu assembler will let you encode instructions like these: fc0a: 12 10 00 02 rrc &0x0200 fc0e: 22 11 rra #4 fc10: 23 52 add #4,#2 My guess is that rrc &0x0200 will fetch from address 0x0200 perform the rotate then write the answer back to address 0x0200, correct? But what would an rra #4 do? The source would be an immediate 4 I assume but is there a destination after the operation? The add #4,#2 assembled into what you would expect

Has anyone implemented __getzone() for IAR Embedded Workbench for MSP430?

梦想的初衷 提交于 2019-12-12 20:00:05
问题 I am having to deal with some time conversions in my application. I would like to stick to using standard library functions as much as possible. Right now I am using a time_t structure as my system time base. However, some devices can sync time to my device, and that time may or may not be UTC. Also, my device will sync time to another device and that time WILL always be UTC. Anyway, I can ask the user what the time zone is of the time that is being synced to my device and whether or not they

printf support for MSP430 micro-controller

你。 提交于 2019-12-12 18:28:27
问题 I am upgrading a fully tested C program for the Texas Instruments (TI) MSP430 micro-controller using a different C compiler, changing from the Quadravox, AQ430 Development Tool to the VisualGDB C compiler. The program compiles with zero errors and zero warnings with VisualGDB. The interrupt service routines, timers, UART control, and more all seem to be working. Certain uses of sprintf, however, are not working. For example: unsigned int duration; float msec; msec = (float)duration; msec =

How does assembly code know if a value is signed or unsigned?

谁说胖子不能爱 提交于 2019-12-12 10:23:54
问题 I get very confused when it seems like sometimes my code treats a certain value as signed and sometimes it treats it as unsigned when comparing values. How does the code know whether a value is signed or unsigned? 回答1: Why do you think that assembly code has to "know" if a value is signed or unsigned? For most operations the results of a signed and an usigned operation are the same: signed int a = 5; signed int b = -6; // 0xFFFFFFFA signed int c; c = a + b; // results in -1 which is

Facing Difficulties in Data Transfer over UART with DMA on MSP430

心已入冬 提交于 2019-12-12 03:57:18
问题 I am collecting 2.4KB(600 bytes * 4) of data from sensors over my MSP430 Controller. And I am using dma to transfer that data over UART to my Linux Processor.Transfer Happens at every 100ms Timer. My DMA setting is as below. DMACTL0 = DMA0TSEL__UCA0TXIFG; DMA0SA = &buff; DMA0DA = &UCA0TXBUF; DMA0SZ = 600; // Block size in bytes DMA0CTL = DMADT_4 | DMASBDB| DMASRCINCR_3 | DMAIE| DMALEVEL_L; // Rpt, inc DMA0CTL|= DMAEN; and my ISR for DMA is as below, __interrupt void DMA_VECTOR_ISR(void) {