Jump to content
43oh

Problems compiling simpleavr's rtc clock and RGB led controll


Recommended Posts

I'm still getting the timer errors, don't know why. The lnk_msp430g2231.cmd error has gone, as it's suposed, but the others still there...

 

I know that the code exceeds only a bit of the available memory and that makes it goes all wrong on CCS, but now the timers shouldn't be a problem. I tried also to compare this code to another one with the timers and interrups but I don't find any error. The code seems equal...

 

Also, now I'm having about 15 erros with other undefined symbols:

undefined   first referenced
  symbol         in file     
 ---------   ----------------
 BCSCTL1     ./rtc-clock.obj 
 BCSCTL2     ./rtc-clock.obj 
 CALBC1_1MHZ ./rtc-clock.obj 
 CALDCO_1MHZ ./rtc-clock.obj 
 DCOCTL      ./rtc-clock.obj 
 P1DIR       ./rtc-clock.obj 
 P1IE        ./rtc-clock.obj 
 P1IES       ./rtc-clock.obj 
 P1IFG       ./rtc-clock.obj 
 P1IN        ./rtc-clock.obj 
 P1OUT       ./rtc-clock.obj 
 P1REN       ./rtc-clock.obj 
 P1SEL       ./rtc-clock.obj 
 P2DIR       ./rtc-clock.obj 
 P2OUT       ./rtc-clock.obj 
 P2SEL       ./rtc-clock.obj 
 TA0CCR0     ./rtc-clock.obj 
 TA0CCTL0    ./rtc-clock.obj 
 TA0CTL      ./rtc-clock.obj 
 WDTCTL      ./rtc-clock.obj 

Are the pin numbers different on different mcu's?

Link to post
Share on other sites

All those references are peripheral memory locations and is defined in

 

C:\TI\ccsv5\ccs_base\msp430\include\msp430g2553.cmd (or whatever device you had configured)

 

This mps430g2553.cmd file is referenced in your lnk_msp430g????.cmd link file (inside your project directory).

 

You can look inside the lnk_msp430g????.cmd file and you can see the link at the very bottom

 

Mine shows..

 

/****************************************************************************/
/* INCLUDE PERIPHERALS MEMORY MAP                                           */
/****************************************************************************/


-l msp430g2553.cmd

I don't know if there is any chance that you had messed up the "target" configuration. I suggest you create a new project w/ G2452 or G2553 and move your code there and see.

 

 

Link to post
Share on other sites

That was really a problem with the copy/paste from github. Thanks again! I'd installed github for windows and downloaded the repo and it is fine now.

The only problem I'm having now is with the clock itself. I plug it on and nothing happens. I press the button and only a simple dot lights on, and the flashes off again...

Link to post
Share on other sites

Are you building building the rtc-clock?

 

If you are building on breadboard chances are sometimes the connections are flaky and the i2c comm may miss. If that happens, the i2c routines may hold the system up.

 

If you don't have a logic analyzer it would be quite difficult to debug.

 

See i2c.h

 

//___________________________________________________
void i2c_snd_rcv(uint8_t cnt, uint8_t sub, uint8_t *data) {
//void __attribute__ ((section (".infomembcd"))) i2c_snd_rcv(uint8_t cnt, uint8_t sub, uint8_t *data) {


    //return;

You may want to uncomment the "return" line so that it returns immediately and you will know if it's causing problems. I.e. w/o i2c you won't be getting / setting the rtc chip. But this is a good way to incrementally debug the system. I.e. make sure the display multiplexing works 1st.

 

I will be on a trip and will not be very active in this forum for a week starting tomorrow. So If you still have questions, ask today or expect a delay.

 

Cheers.

 

 

Link to post
Share on other sites

I guess that it works :grin:

 

But now I'm confused: after the clock is seted up it should change the minutes, right? But it stays on the time I put there and don't move... The seconds change (i guess) but the rest is stopped :?

 

Thank you so much simpleavr ;-)

 

It must be your 1st project since you are so happy  :smile:

 

w/ I2C turned off, we can confirm that the led multiplexing and most of everything else works.

 

The reason that the clock won't advance the minutes is it does not by design.

 

I used timer to advance the seconds but it's DCO clock and not 100% accurate. So w/ the RTC clock via I2C, the strategy is to count up to 60 seconds and talk to the RTC chip via I2C and "get" and "update" the hour / minute / seconds etc.

 

But since your I2C is not working, this did not happen. You may want to change the code to make it happen w/o RTC though.

 

So the next step is to debug your I2C. I would 1st start w/ validating, cleaning up, or rewiring everything between the RTC and the MSP430. Then may be tried and adjust the I2C timing (add some delays), check i2c.h

 

// bitbang timing we may need for faster clocks or slower buses
//
//#define QDEL  _delay_us(5)
//#define HDEL  _delay_us(10)
//#define QDEL  brief_pause(1)
//#define HDEL  brief_pause(2)
//#define QDEL  asm("nop")
//#define HDEL  asm("nop")
#define QDEL    ;
#define HDEL    ;

My experience is that breadboarding is not good for high-speed anything because of noise, you can try to introduce bypass caps etc. But w/o a logic analyser, be prepare to spend time to get it work.

 

Link to post
Share on other sites

This isn't my first project, but is almost there :$

 

Also I noticed now that there is another "error". When I'm on "Seconds mode" the counter goes up to 79. Is that supose to happen, or is just part of the error?

 

If the seconds are counting, I can confirm that the RTC is working, or not?

 

I don't know if I need some delay, but I'll try that. About the breadboard I'm using one like you show on the video (these small breadboards are awesome for this "portable" projects :) ) but I'll try with a bigger one.

 

 

PS: please change this picture on your web page. The RTC and the cap are oriented to the wrong side. After my first attempt to build this (two days ago) I follow that image and noticed that the cap is wrong but I don't get that the RTC is also rotated and after a couple of seconds with the breadboard connected to 2 AA batteries it start getting hot. I think it was the crystal, but, I change also the RTC just to play safe and avoid hardware failures.

Link to post
Share on other sites

Did you uncomment the i2c function so it now tries to talk to the RTC chip?

 

For each second the clock checks if sec exceeds 0x60 (bcd), if so, it asks for a READ via state machine.

 

                time[sec] = bcd_chk(time[sec]+1, 1);
                if (time[sec] >= 0x60) // sync w/ rtc every minute
                    state |= ST_READ;

A little bit later, we because of the ST_READ state, we talk to the RTC chip via I2C

 

 

        if (state&(ST_UPDATE|ST_READ)) {
            _BIC_SR(GIE);                   // disable interrupt
....

                i2c_snd_rcv(15, 0, (uint8_t*) &time[ctl1]);
            }//if
            i2c_snd_rcv(I2C_READ|14, 1, (uint8_t*) &time[ctl2]);
            if (time[ctl2]&0x08) {
                state |= ST_BUZZ;   // alarm happened
                mode = 1;
            }//if
            state &= ~(ST_UPDATE|ST_READ);
And after that, we do check our results from RTC chip, if second is greater than 0x60, it makes no sense and we assume failure. We then set the state machine to do a write (which resets the chip somehow) at the next iteration.
 
            if (time[sec]>=0x60) {
                // we shouldn't be reading this unless rtc gone bad (backup powersheetji failed)
                // so we will loop again and write to clear the "bad" flag
                state |= ST_UPDATE;
            }//if
            state |= ST_REFRESH;

But if the I2C or the RTC chip is bad somehow, there will be no successful results from the RTC chip. And this goes on w/ the timer clicks and the seconds will advance beyond 60 seconds.

 

So you still have a I2C problem, w/o a logic analyzer, you can only adjust timing and try.

 

P.S. thanks for the tip on the schematic, I will get to it when I can (I hope that did not blow your chips  ;-) )

 

 

 

 

 

 

Link to post
Share on other sites

Where's that function you're mentioning? It's on the "library" i2c.h? I'm searching there and theres only 3 functions commented: "static void __inline__ brief_pause(register uint16_t n)", "void i2c_init()" and "uint8_t i2c_exists()". Are these one you'r talking about?

 

So, the best way is to activate those delays on the beggining to check if there's a problem with those?

 

 

 

 

P.S. thanks for the tip on the schematic, I will get to it when I can (I hope that did not blow your chips  ;-) )

 

I don't think so. The mcu seems that's working and maybe the RTC is working too, but I can only check that after I get this working properly :(

 

 

Thank you for all the patience :oops:

Link to post
Share on other sites

They delays are in i2c.h, HDEL and QDEL, as default it is defined as ;, which does nothing, You could try to insert nops (assembler no-operation) to make the i2c comm go slower, that could help, they delay_us() / brief_pause() may or may not be available depending on your compiler. You can try __delay_cycles() which I think is available.

 

Or just try

#define HDEL asm("nop")
#define QDEL asm("nop")

or more

#define HDEL asm("nop"); asm("nop")
#define QDEL asm("nop"); asm("nop")

Also there are many "bad" clock crystals on ebay. I got bitten a while ago when I brought 10 and 6 of them won't work. If you have more crystals try to swap them and see. You are also suppose to have 22pF caps w/ the crystals. Just saying that could be a source of problem too.

 

 

 

 

Link to post
Share on other sites
From the datasheet
 
8.1 CLKOUT output
A programmable square wave is available at the CLKOUT pin. Operation is controlled by
the register CLKOUT_control at address 0Dh. Frequencies of 32.768 kHz (default),
1.024 kHz, 32 Hz, and 1 Hz can be generated for use as a system clock, microcontroller
clock, input to a charge pump, or for calibration of the oscillator. CLKOUT is an open-drain
output and enabled at power-on. If disabled it becomes high-impedance.

You might want to check if the RTC chip is up or not. Should be able to measure something on this CLKOUT pin if your crystal is oscillating. Just a guess, haven't really try it.

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.

×
×
  • Create New...