-
Content Count
925 -
Joined
-
Last visited
-
Days Won
103
Everything posted by oPossum
-
Block read with CRC. Return will be zero if CRC is valid, or non-zero for invalid CRC. Length includes CRC. unsigned read_block(unsigned char *d, unsigned len) { unsigned crc = 0; unsigned n; for(; { crc ^= *d++ = owrb(); if(!--len) break; n = 8; do crc = (crc & 1) ? ((crc >> 1) ^ 0x8C) : (crc >> 1); while(--n); } return crc; }
-
Here is updated one wire code that is a bit smaller. More code is shared between the zero and one tx/rx. I have also added four functions for byte/word read/write, and an export for the bus reset so it can be called directly. Core asm code... owww ; - Write word mov #16, R13 ; jmp owdx ; owrw ; - Read word mov #-1, R12 ; mov #16, R13 ; jmp owdx ; owwb
-
PIC code looks good. Gives me some ideas to improve MPS430 code. - Kevin (oPossum)
-
Bypass caps would be my #1 suspect. They must be close to the chip, proper value and type. Unhandled interrupts can also cause this behavior. Post your schematic and PCB picture if you can.
-
In C unsigned long phase_inc; unsigned long phase_acc; phase_acc += phase_inc; In assembly .bss phase_inc, 4 .bss phase_acc, 4 add &phase_inc, &phase_acc addc &phase_inc + 2, &phase_acc + 2 Variables are passed in R12 to R15, and then the stack. slau132d section 6.4.1 page 100, section 6.5 page 102
-
Proteus VSM MSP430 edition
-
RadioShack has MPS2222A. OnSemi's verson of the PN2222A.
-
The IR pulses have a aprox 50% duty cycle (typ) and come in bursts, so the average current will be under 500 mA. A transistor like the PN2222 that has 500 mA continuous / 1 A peak spec is common for this application. The IR led is typically rated at 1.0 to 1.5 A peak for a short duration. The continuous current is much lower - typ 50 to 100 mA. Hfe (beta) is important, exactly how important depends on the application. As a general rule, higher is better (but not always). An oscillator or amplifier is a more sensitive application than a switch.
-
I forgot a few files in the zip. It is fixed now. Main.c is also updated to show temperature in deg C and F.
-
2N3904 is a bit weak for that application. PN2222 would be a reasonable replacement. The pinout is different, so you will have to carefully bend the leads to go to the correct PCB pad. The Vf of an IR led is typically 1.2 to 1.5 V. Peak current could be close to 1 A in that circuit.
-
15v NAND? what one? I missed it.
-
40107 dual 2 input NAND open drain The spec sheet is unclear if the outputs can tolerate voltage above the supply. TI ST
-
Check the specs for max output voltage. It is typically 6 to 7 volts. 7401, 7403, 7438, etc.. NAND would be the type of gate needed.
-
Something to think about...
-
Build a prototype of at least one H bridge on a breadboard or protoboard before you commit to having a PCB made. You will probably want to use a PNP transistor on the high side of the H bridge. Building and testing a prototype will make it very clear why.
-
I have bus scan and CRC written, but not yet tested.
-
Here is a basic library for 1-wire communication. It works with CPU frequency of 1 MHz or higher. Carefully crafted assembly code is used to allow operation over a wide CPU clock frequency range. There are only two functions. One for setup and the other for all communication tasks. // one_wire.h void one_wire_setup(volatile unsigned char *dir, volatile unsigned char *in, unsigned bitmask, unsigned mhz); int owex(int data, unsigned bits); The library is initialized by a call to one_wire_setup(). The arguments specify the I/O pin and clock frequency. An example for P1.4 at 16
-
That is correct. The low pass filter is important to get a good sine wave at near 50% the sample rate. A 12 db/oct sallen-key or similar filter is generally practical for 40% of sample rate. The dsPIC33FJ128GP802 is also great chip for audio synth. It has dual 16 bit oversampling audio DACs and comes in DIP and SMD packages. It is about twice as fast as the fastest MSP430. It have written several variations of NCO code for the dsPIC in assembly. Here is an example of a NCO with interpolation and level control... sl osc01_phacch, WREG ; Get phase accumulator
-
That is linear interpolation. It allows the use of a smaller sine table with reasonable distortion. In this specific case it could be eliminated with little affect on quality. If the size of the sine table was reduced, then it would be much more important. If you are going to look at audio with a 'scope, then an analog scope is generally better than a digital. Just listening to audio can often reveal problems that are hard to see on any scope. For audio work a distortion analyzer and spectrum analyzer (not a scope with FFT) are extremely useful, but quite expensive for anything of
-
All pointers are the same size sizeof(char *) == sizeof(int *) == sizeof(double *) == sizeof(void *) So casting from a pointer to one type to a pointer to another type is not a problem.
-
struct sensors_struct foo; // Received data will be copied to foo SMPL_Receive(linkIDTemp, (uint8_t*)&smpl_buffer, &len); if(len == sizeof(foo)) { memcpy(&foo, &smpl_buffer, len); } else { // rx data is the wrong size }
-
srand(adc_rnd());
-
ditto for MSPGCC and IAR. They may promote unsigned to long int, and make the code larger.