Jump to content
Sign in to follow this  
SugarAddict

Eagle first attempt...

Recommended Posts

I've ordered a couple times from Dorkbot PDX as well. Yes, they've adjusted their colour. My first set was a blue colour and second was more purple. Sorry, the second isn't well colour corrected, so it's not the exact colour. I also have light from the side, so the traces show up more than in real life.

 

If you submit Gerbers instead of Eagle Files, you'll get a 1:1 with what you submit. Use a gerber viewer to varify everything is exactly the way you want it. Generally, I'm too lazy to even verify my gerber files now.

 

post-1302-135135497396_thumb.jpg

post-1302-135135497405_thumb.jpg

Share this post


Link to post
Share on other sites

The frequency adjuster simply multiplies or halves an input signal frequency to whatever you program it with. It's for cars/motorcycles that use tach displays from different engines. It simply takes the signal over an optocoupler and sends the new signal out with a transistor. The code is pretty funky, since the F2001 only has a single timer to do both input capture and output timing. The most I've had it do is someone required a 1:16 frequency up convert. Maybe I'll clean up the code and put it in Projects.

 

The serial display is a 4 digit 7seg display I'm working on for an LC-1 UEGO controller to display A/F ratio. I hope to move the design over to a Launchpad and make it open source. There are a lot of people running the LC-1 wideband and a custom display for about $20 in parts, I think would work out well.

Share this post


Link to post
Share on other sites

So I got the components and built a board, the only problem I'm really having is that when I push the BIT2 button (minutes) when I do it 20+ times the hour lights come on and the program halts... What am I doing wrong that this would happen? Should I instead change S3 to function as "time programming mode" and halt everything while S1 and S2 set the time and then resume from there? I'm wondering if there's something I'm stomping over that I shouldn't...

 

#include "msp430g2231_mod.h"

unsigned int time16 = 0, SecOne = 0, SecTen = 0, MinOne = 0, MinTen = 0, HourOne = 0, Counter = 0, Flipper = 0, zerotime16 = 0;

void main()
{
WDTCTL = WDTPW + WDTHOLD;						// Stop WDT

BCSCTL1 = CALBC1_16MHZ;                      // Set range  
DCOCTL = CALDCO_16MHZ;                       // Set DCO step + modulation


BCSCTL1 &= ~XTS;								// External source is LF
BCSCTL3 &= ~(LFXT1S0 + LFXT1S1);				// Watch crystal mode
BCSCTL3 |= XCAP0 + XCAP1;						// ~12.5 pf cap on the watch crystal as recommended

__delay_cycles(5000);

P1DIR &= ~(BIT1|BIT2|BIT3);						// 1.1, 1.2, 1.3 are buttons for hours, minutes, seconds respectively.
P1SEL &= ~(BIT1|BIT2|BIT3);
P1OUT |= (BIT1|BIT2|BIT3);						// Set to high
P1REN |= (BIT1|BIT2|BIT3);						// Resistor enabled
P1IE |= (BIT1|BIT2|BIT3);						// Interrupt enabled
P1IES |= (BIT1|BIT2|BIT3);						// Edge select
P1IFG &= ~(BIT1|BIT2|BIT3);						// Clear interrupt flags

P1DIR |= (BIT0|BIT7|BIT4);						// 1.0 for latching, 1.4 and 1.7 for bit 17 and bit 18 of time
P1OUT |= BIT0;									// Set to high
P1OUT &= ~(BIT7|BIT4);							// Set to low

USICTL0 |= USIPE6 + USIPE5 + USIMST + USIOE;	// Out & clk enable, SPI Master
USICTL1 |= USICKPH + USIIE;						// Counter interrupt
USICKCTL = USIDIV_0 + USISSEL_2;				// /1 ACLK
USICTL0 &= ~USISWRST;							// Enable USI
USICNT = USI16B;								// Enable 16 bit

CCTL0 = CCIE;									// CCR0 interrupt enabled
CCR0 = 255;									// Duration
TACTL = TASSEL_1 + MC_1 + ID_0;					// ACLK, upmode

_bis_SR_register(LPM3_bits + GIE);				// Enter LPM3 w/ interrupt
}

// Timer A0 interrupt service routine
#pragma vector = TIMERA0_VECTOR
__interrupt void Timer_A (void)
{
Counter++;
if(Counter>127)
{
	Counter = 0;
	SecOne++;
	if(SecOne>9)									//Progress the seconds ten position?
	{
		SecOne=0;
		SecTen++;
		if(SecTen>5)								//Progress the minutes one position?
		{
			SecTen=0;
			MinOne++;
			if(MinOne>9)							//Progress the minutes ten position?
			{
				MinOne=0;
				MinTen++;
				if(MinTen>5)						//Progress the hours position?
				{
					MinTen=0;
					HourOne++;
					if(HourOne>12)
						HourOne = 1;
				}
			}
		}
	}
}

Flipper ^= 1;
if(Flipper == 1)
{
	time16 = 0;
	time16 |= (HourOne&0x0003);
	time16<<=3;
	time16 |= MinTen;
	time16<<=4;
	time16 |= MinOne;
	time16<<=3;
	time16 |= SecTen;
	time16<<=4;
	time16 |= SecOne;
	USISR = time16;									// Move 
	USICNT |= 16;									// Start USI
	if((HourOne&0x0004) == 0x0004)	P1OUT |= BIT4;
	else P1OUT &= ~BIT4;
	if((HourOne&0x0008) == 0x0008)	P1OUT |= BIT7;
	else P1OUT &= ~BIT7;
}
else
{
	USISR = zerotime16;									// Move 
	USICNT |= 16;									// Start USI
	P1OUT &= ~BIT4;
	P1OUT &= ~BIT7;
}

}

// USI interrupt service routine
#pragma vector = USI_VECTOR
__interrupt void USI_TXRX (void)
{
USICTL1 &= ~USIIFG;                     // Clear pending flag
P1OUT &= ~0x01;                     // Latch data
P1OUT |= 0x0001;
}

// Port 1 interrupt service routine
#pragma vector=PORT1_VECTOR
__interrupt void P1ISR(void)
{
if(P1IFG & BIT1)
{
	SecOne++;
	if(SecOne>9)
	{
		SecOne = 0;
		SecTen++;
		if(SecTen>5)SecTen = 0;
	}
	P1IFG &= ~BIT1;
}
if(P1IFG & BIT2)
{
	MinOne++;
	if(MinOne>9)
	{
		MinOne = 0;
		MinTen++;
		if(MinTen>5)MinTen = 0;
	}
	P1IFG &= ~BIT2;
}
if(P1IFG & BIT3)
{
	HourOne++;
	if(HourOne>12)
	{
		HourOne = 1;
	}
	P1IFG &= ~BIT3;
}
}

 

28vd0yt.jpg

Share this post


Link to post
Share on other sites
[10] ...

[10] * SugarAddict facepalms

[10] what're you trying to do?

[10] My binary clock... I think I found the problem... it's functioning nicely now, lmfao

[10] Am I not supposed to enter LPM0 when I'm done with an interrupt?

[10] Is that only supposed to be in the main code?

[10] _bis_SR_register(LPM0_bits + GIE);

[10] commenting that out fixed all the buttons

[11] SugarAddict: if you enter LPM0 in the interrupt handler, the program will not return to your out-of-interrupt code

[11] Oh...

[11] I assume you have an interrupt firing for a clock tick, and you do all of your updates then...

[11] I can see that being bad

[11] lol

[11] in that case, enter the LPM mode that shuts down everything except for your interrupt source - and then, on the interrupt source, update everything and then re-enter the LPM mode

[11] (I think LPM3 or LPM4 should be doable for a 32kHz crystal, for instance)

[11] USI?

[11] you have to read the documentation

[11] * SugarAddict nods.

[11] each LPM mode shuts off more clock sources

[11] you shut down all of the ones that you don't use

[11] Only using the 32khz source on this

[11] they *all* disable the processor core itself, so you'll save that energy

[11] So would I clear lpm at the start of my interrupt and have a for(;;){_bis_SR_register(LPMx_bits + GIE);} in main? or just leave it as _bis_SR_register(LPMx_bits + GIE); in main?

[11] I don't exactly understand the question; when I was doing timer-fired code, my main was a while (1) loop that, at the end of the loop, set the LPM mode on. In my interrupt, I disabled LPM mode. That way, every time the interrupt fired I woke up the main (out-of-interrupt) code for one cycle, and then it went to sleep again

[11] you clear LPM on the *exit* of an interrupt - it's always cleared for the duration of the interrupt

[11] (or, more correctly, it's always cleared on the entrance to an interrupt - but the LPM state, by default, is restored on the return from interrupt)

[11] Ok

[11] so if there is nothing in the main, why wake it?

[12] SugarAddict: if there's nothing in main, *don't* wake it - just set up everything, and never return to main

[12] ...I structured my program so that all of the work was done in main, and the interrupt just woke main up

[12] you could easily put all of the work in the interrupt routine...

[12] then just don't change your LPM bits at all, and when you return from the interrupt handler the processor immediately goes back to sleep

[12] the MSP430 has a pretty nice power management set

[12] Err: k, I was under the impression I had to put it back to sleep after an interrupt. Thanks :)

[14] no problem

[14] (note that what I said is true for the processor itself - your compiler might have different semantics... gcc doesn't muck with those bits unless you tell it to, anyway)

[14] I would assume that CCS/IAR behave similarly

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...