Jump to content
43oh

oPossum

Members
  • Content Count

    925
  • Joined

  • Last visited

  • Days Won

    103

Everything posted by oPossum

  1. So the basic compact serial tx is this... mov #2, R15 ; Serial output bitmask or #0x0300, R12 ; Stop bit(s) jmp bit_low ; Send start bit... bit_loop ; * Add delay here if needed* rra R12 ; 7 Get bit to tx, test for zero jc bit_high ; 8->9 If high... bit_low bic.b R15, &P1OUT ; 1->4 Send zero/start bit jmp bit_loop ; 5->6 Next bit... bit_high bis.b
  2. Yeah, sorry Rob. I got caught up in oPossum's "this code is optimal (can not be done with fewer instruction words or cycles)" claim, which sounded like a challenge to me (grin). Thanks for taking up the challenge. You got me to take another look at optimizing the code. I have been programming PIC in assembly for about 20 years. Just learning the TMS430. I like it, but miss the btfss, btfsc, bsf, bcf, and btf instructions that the PIC has. CCS is a bit unstable and slow, I like MPLAB better.
  3. I'm not following you. Sounds like an interesting caveat though. Is there a page number in SLAU144h or SLAU131e I can refer to? Regards, Mike "3.2.4 Constant Generator Registers CG1 and CG2" (page 47) in "MSP430x2xx Family User's Guide" (slau144h) It is a quirk of the MPS430 architecture that allows smaller, faster code and is used by several pseudo-ops.
  4. Be aware that constants -1, 0, 1, 2, 4, and 8 are one word and one cycle shorter than all other constants. Use caution with constants in timing critical code.
  5. Just change the serial_setup() call. For example, 57600 bps with 16 Mhz clock... serial_setup(1 << 1, 16000000 / 57600);
  6. No, the frequency is part of the protocol specification. Timing alone is not enough information.
  7. It provides all the necessary info needed to reproduce a remote's transmission or respond to a remote control. So, if you want to make your own remote or make something that responds to an existing remote, then this device will provide essential information.
  8. Nice code. I like it. Great to have another MSP430 asm programmer here. To count cycles in CCS debugger, select Clock Enable from the Target menu. Note that the cycle count of the first instruction executed after enabling the clock may be incorrect, usually +1. Double click on the clock to reset it. Here is revised code that uses 25 words, 17 cycles/bit minimum, and can be packaged as a library. serial.asm .cdecls C, LIST, "msp430g2211.h" .bss bit_dur, 2 .bss bit_mask, 2 .text .global serial_setup, putc, puts seria
  9. Try this. Works on Launchpad with "MSP430 Application UART" at 9600,8,N,1 main.c #include "msp430g2211.h" // or g2231 // Functions in serial.asm (this really should be in a header file) void putc(unsigned); void puts(char *); void main(void) { char c; DCOCTL = 0; BCSCTL1 = CALBC1_1MHZ; DCOCTL = CALDCO_1MHZ; WDTCTL = WDTPW + WDTHOLD; P1DIR = 0xDA; P1REN = 0x25; P1OUT = 0x07; P1SEL = 0x11; puts("Test\r\n"); for(c = 33; c < 127; ++c) putc(c); puts("\r\n"); for(;; } serial.asm .cdecls C, LIST, "msp430g2211.h" ;
  10. Uses software delay loop instead of timer [interrupt] for small code size. Minimum bit duration is 18 clock cycles. One cycle granularity. I think this code is optimal (can not be done with fewer instruction words or cycles). tx_char ; Char to tx in R14 ; R10, R11, R12, R15 trashed mov #65553 - 104, R10 ; Bit duration (18 minimum) mov #0x02, R15 ; Serial output bitmask mov #10, R12 ; 10 bit times (may be reduced to 9 at high bit rates) bi
  11. A typical frequency counter will count cycles for a period of one second and display the resulting count. This will not work for measuring the IR remotes's carrier frequency because the carrier is being keyed on and off (OOK - on off keying). A much shorter gate time is required to get a proper measurement. A 100 us gate time is used as shown in this diagram... The first and last non-zero counts will be excluded from the carrier frequency calculation because the carrier was probably not on for the entire period. The inner counts are summed and the period durations are also summed. Th
  12. Yes, most TSOPxxxx demod modules are readily available. It is just the code learning modules that are not in stock anywhere.
  13. No stock at Digikey, Mouser, Newark, Future, Arrow or Avnet. I don't sample parts that I can't buy.
  14. There is a cool trick that can be used with LEDs (IR and visible) when repetition rate is low ( a few Hz at most). Charge the LED with reverse bias (diodes have a small capacitance) and then measure the time it takes for the charge to drop below the logic threshold of the micro. The small photocurrent generated by the LED discharges the small charge stored in it. The shorter the discharge time, the brighter the light. Elegant and effective.
  15. To measure the CIR carrier frequency, each individual pulse of IR must be detected. Common IR demodulator modules can not do this - they respond to a burst of IR, not each pulse. There are parts made for this specific application such as the Vishay TSOP98200 and TSOP98260. Unfortunately these parts are difficult to obtain. There are general purpose IR detectors like the Fairchild QSE159 and Osram SFH5140, but they require 5 volts. A photodiode and a transimpedance amplifier works well, but requires careful construction (not a breadboard) to work well. I used an ordinary IR LED
  16. The following posts describe a simple method of CIR capture that can be done with almost any MSP430. The prototype shown uses the Launchpad with a MSP430G2211. This device that will show in detail the signal sent by IR remote controls. It measures the carrier frequency, on duration, off duration, and pulse count per burst. The Launchpad fitted with a MSP430G2211 running at 1 MHz sends all this information to a PC where a Windows program is used for graphic display. Capture is done in real time and there is no limit to the duration. The following screen captures are from a remote using
  17. Inline asm version void tx(unsigned c) { __asm(" mov 0(SP), R14"); // Get the char passed on the stack to R14 // __asm(" mov #0x02, R15"); // Setup bitmask in R15 // __asm(" bic.b R15, &P1OUT"); // 0 Start bit __asm(" jmp $ + 2"); // // __asm(" rrc R14"); // Bit 0 __asm(" jc $ + 18"); // __asm(" bic.b R15, &P1OUT"); // 9 __asm(" nop"); // __asm(" rrc R14"); // Bit 1
  18. To measure the CIR carrier frequency, each individual pulse of IR must be detected. Common IR demodulator modules can not do this - they respond to a burst of IR, not each pulse. There are parts made for this specific application such as the Vishay TSOP98200 and TSOP98260. Unfortunately these parts are difficult to obtain. There are general purpose IR detectors like the Fairchild QSE159 and Osram SFH5140, but they require 5 volts. A photodiode and a transimpedance amplifier works well, but requires careful construction (not a breadboard) to work well. I used an ordinary IR LED
  19. Here is some code that can tx at 115.2 kbps while running at only 1 MHz clock. This can be useful for "printf debugging" with minimal impact on code speed. The bit time of 115.2 kbps is aprox 8.68 us. The timing granularity at 1 MHz is only 1 us, so dithering is used to maintain correct average bit time. Most UART look at the middle of the bit, so this generally works well. The jitter is under 500 ns as shown in the following table. ; Bit Exact Int Delta Error ; ---------------------------------- ; Start 0.00 0 - - ; 0 8.68 9 9 +0.32 ; 1 17.36 17 8 -0.36 ; 2 26.04 26
  20. I have my contest idea working, so I will describe what is is. There is still some work to be done, so code and schematic will be posted later. EDIT: Created a thread for this project here This thread will be updated after the whole project has been presented.
  21. The spec says the mic bias voltage must be above 700 mV and less than 1750 mV for a headset. Try a shunt made from two 1N4148 or similar diodes in series connected to the mic line.
  22. OK, that creates an .asm and .lst files, but the disasm window is still blank. So it seems the disasm window works only with the debugger.
  23. Is there a way to get CCS to display a disassembly in the C/C++ perspective? The window is blank even after clicking refresh. It works in Debug perspecive, but even then seems rather flaky.
  24. I am using Code Composer Studio (CCS), not IAR Kickstart - sorry that wan't clear. Target is the Launchpad with G2231. It is running on the hardware because the I/O responds as expected. A software simulator would certainly be a great addition to CCS. I have also noticed that the first cycle count after enabling the timer is often 1 higher than it should be. Anyone else see this behavior?
  25. Enabling the clock really slows down execution. It seems to single step and count the cycles of each instruction. Is this a limitation of the G series parts or do all MSP430 lack a hardware instruction cycle counter? Is there any way to enable/disable the clock with the keyboard?
×
×
  • Create New...