bill Posted September 5, 2007 Report Share Posted September 5, 2007 Does anyone have any suggestion, to connect an external "clock", to the core ?I'm thinking of a Hour/Min/Sec clock, So an application could "know" what time is it,(then trigger an action at a certain time)I think it could be very interesting, but dont know yet how it could be done ;) Quote Link to comment Share on other sites More sharing options...
ris8_allo_zen0 Posted September 5, 2007 Report Share Posted September 5, 2007 Hi bill,I know about the PCF8583 or the DS1307, a real-time clock and calendar with IIC interface. There are plenty of different chips and also relative code for PIC to use them. Just look for them!RAZ Quote Link to comment Share on other sites More sharing options...
sneakthief Posted September 6, 2007 Report Share Posted September 6, 2007 http://www.futurlec.com/Mini_PCF8583.shtmlhttp://www.futurlec.com/Mini_DS1307.shtml Quote Link to comment Share on other sites More sharing options...
bill Posted September 6, 2007 Author Report Share Posted September 6, 2007 thanks !!!!those lil boards looks great ;D Quote Link to comment Share on other sites More sharing options...
Sasha Posted September 6, 2007 Report Share Posted September 6, 2007 Hey bill, can you tell us something more about your idea? Quote Link to comment Share on other sites More sharing options...
stryd_one Posted September 6, 2007 Report Share Posted September 6, 2007 I have some FX machines that wish me a happy birthday :) Quote Link to comment Share on other sites More sharing options...
bill Posted September 6, 2007 Author Report Share Posted September 6, 2007 Hey bill, can you tell us something more about your idea?I dont have a very precise idea, but i like to experiment, learn about ic2, and use the midibox for other purpose than pure midi application (like robotic or domotic). :) Quote Link to comment Share on other sites More sharing options...
Sasha Posted September 6, 2007 Report Share Posted September 6, 2007 Cool. I have an idea of using midibox for some robotic purposes but as I`m not programmer I can only use MB apps as it is without any customization.I would really like to see what different you did with MB platform. I have some FX machines that wish me a happy birthday SmileyThat is funny, but same time, reminds me that we are distancing from the people and getting better with machines. Quote Link to comment Share on other sites More sharing options...
stryd_one Posted September 6, 2007 Report Share Posted September 6, 2007 I dunno, I always think about the programmers when it does that ;)You could make a SID alarm clock :) Quote Link to comment Share on other sites More sharing options...
Sasha Posted September 6, 2007 Report Share Posted September 6, 2007 That would be so cool. :D Quote Link to comment Share on other sites More sharing options...
stryd_one Posted October 4, 2007 Report Share Posted October 4, 2007 Just saw these on ebay...bit more expensive though! Thought I'd post them in case futurlec runs out or something.PCF8583 Real Time Clock Mini BoardDS1307 MCU Add-On Board DS1307 Real Time Clock Quote Link to comment Share on other sites More sharing options...
bill Posted October 23, 2007 Author Report Share Posted October 23, 2007 Dear forum,I bought a board like this one to experiment IIC : http://www.futurlec.com/Mini_DS1307.shtmlhttp://www.rev-ed.co.uk/docs/DS1307.pdfso i connected the board to the core without problem,and initialised the IIC like this :void Init(void) __wparam { MIOS_IIC_Stop(); // init IIC interface } then, looking at the speakjet code i did this : unsigned char IIC_TransmitStart(unsigned char _slave) __wparam { unsigned char retry_ctr; // start IIC access MIOS_IIC_Start(); // send address retry_ctr = 0; while( !MIOS_IIC_ByteSend( _slave ) ) { // slave has sent a NAK - retry 255 times MIOS_IIC_Stop(); if( ++retry_ctr == 255 ) return 0; MIOS_IIC_Start(); } return 1; } and this : (slave value is 0xD0) void DISPLAY_Init(void) __wparam { MIOS_LCD_Clear(); if(!IIC_TransmitStart(slave) ){ MIOS_LCD_CursorSet(0x00); MIOS_LCD_PrintCString("IIC Transmit error !"); }else{ MIOS_LCD_CursorSet(0x00); MIOS_LCD_PrintCString("IIC Transmit OK"); } } at this point, everything seems ok, i have "IIC Transmit OK" :) then, i try to read some values so i did : void GET_TIME(void){ MIOS_IIC_Start(); // start IIC MIOS_IIC_ByteSend(slave); // send device address - // set bit #0 to notify a read!!! // don't continue if IIC device not available if( MIOS_BOX_STAT.BS_AVAILABLE){ b0 = MIOS_IIC_ByteReceive(); MIOS_IIC_AckSend(); // send acknowledge b1 = MIOS_IIC_ByteReceive(); } MIOS_IIC_NakSend(); // send disacknowledge!!! MIOS_IIC_Stop(); // stop IIC MIOS_LCD_CursorSet(0x40); MIOS_LCD_PrintHex2(b0); MIOS_LCD_PrintCString(":"); MIOS_LCD_PrintHex2(b1); }but all i read, whenever i call this function is just some random values, instead of seconds :-\maybe this project is a little too complicated for me, to be honest, i dont know exactly how it's supposed to work,but i guess i'm must not be that far from the goal, so i hope some people here can explain me what i did wrong, or did not :)thanks for reading ! Quote Link to comment Share on other sites More sharing options...
bill Posted October 23, 2007 Author Report Share Posted October 23, 2007 I know slave adress should be 0xD1 (1101000+1) (the 1 is for "read" mode)I did enable clock stretching with MIOS_IIC_CtrlSet(0x01);but my received bytes are still random... :-\ Quote Link to comment Share on other sites More sharing options...
bill Posted October 23, 2007 Author Report Share Posted October 23, 2007 I'm sorry to ask again for help, and to look like an asshole, but i have one more question that maybe some of you could answer.The DS1307 doc (http://www.rev-ed.co.uk/docs/DS1307.pdf) say :RTC AND RAM ADDRESS MAPThe address map for the RTC and RAM registers of the DS1307 is shown in Figure 2. The real timeclock registers are located in address locations 00h to 07h. The RAM registers are located in addresslocations 08h to 3Fh.So, i'm only interested on the "real time clock registers" at the moment, so, all i need to get is the 8 first bytes after this MIOS_IIC_Start(); // start IIC MIOS_IIC_ByteSend(slave); // send device addressis that right ? Quote Link to comment Share on other sites More sharing options...
TK. Posted October 23, 2007 Report Share Posted October 23, 2007 The code looks correct.But the datasheet says, that there is an address pointer which will be incremented on each read operation. It isn't explicitely mentioned, but I would expect that you need to reset the pointer by hand when you want to read from zero.So, the code should look somehow like this (quick hack, errors can be expected)MIOS_IIC_Start();MIOS_IIC_ByteSend(0xd0); // slave address, write operationMIOS_IIC_ByteSend(0x00); // set address pointer to 0MIOS_IIC_Stop();MIOS_IIC_Start();MIOS_IIC_ByteSend(0xd1); // slave address, read operationb0 = MIOS_IIC_ByteReceive();MIOS_IIC_AckSend();b1 = MIOS_IIC_ByteReceive();MIOS_IIC_NakSend();MIOS_IIC_Stop();[/code]once this sequence is working, you can add all the robustness stuff, like check for BS_AVAILABLE, etcBest Regards, Thorsten. Quote Link to comment Share on other sites More sharing options...
bill Posted October 24, 2007 Author Report Share Posted October 24, 2007 Thank you Thorsten,your example help me a lot (to understand how it's supposed to work), today i found this http://www.techdesign.be/projects/routines/ds1307_void_a.htmThe DS1307 datasheet is quite confusing because the read routine seems not to be the same as with an i²c EEPROM. However, it is, basically. So when reading from the DS1307 (=Slave) and seen by the PIC's point of view (=Master), we have to:1) Send a START, write the device address (0xd0) (last bit is 0 for write), wait for ACK.2) Write the word address (sets the first register to read from, which is 0x00 here), wait for ACK.3) Send a REPEATED START, write the device address again (0xd1) (last bit is 1 for read), wait for ACK.4) Read the first byte, wait for ACK.5) Repeat step 4) for next bytes.6) Read the last byte, no wait for ACK, send STOP. We have to repeat this whole cycle each time we start reading the DS1307 registers, otherwise they will be incremented automatically, and not set to zero.This is basically what you wrote yesterday (minus the first "STOP")I also found some code supposed to work : http://jambonbill.free.fr/midibox-kb/MBHP-CLOCK/main.c.txthttp://jambonbill.free.fr/midibox-kb/MBHP-CLOCK/ds1307.c.txtI will continue to experiment this evening ;) Quote Link to comment Share on other sites More sharing options...
bill Posted October 24, 2007 Author Report Share Posted October 24, 2007 now it works ;D more details soon ! Quote Link to comment Share on other sites More sharing options...
TK. Posted October 24, 2007 Report Share Posted October 24, 2007 According to the IIC spec, it is allowed to omit the STOP so long the same device is accessed again, but I felt saver to show you an example with stop/start, as I know that e.g. the IIC slave of PIC16F88 cannot handle the "restart" condition properlyBest Regards, Thorsten. Quote Link to comment Share on other sites More sharing options...
bill Posted November 5, 2007 Author Report Share Posted November 5, 2007 if someone is interested, let me know, so i do a user project page for this :) Quote Link to comment Share on other sites More sharing options...
Sasha Posted November 6, 2007 Report Share Posted November 6, 2007 if someone is interested, let me know, so i do a user project page for this SmileyGreat! :) Please, do it. Thank you Bill. Quote Link to comment Share on other sites More sharing options...
audiocommander Posted November 6, 2007 Report Share Posted November 6, 2007 yeah, that would be cool :D Quote Link to comment Share on other sites More sharing options...
bugfight Posted November 6, 2007 Report Share Posted November 6, 2007 Great! :) Please, do it. Thank you Bill.me 2 Quote Link to comment Share on other sites More sharing options...
TK. Posted November 6, 2007 Report Share Posted November 6, 2007 Nice work!Btw.: your MIOS installation is outdated (MIOS V1.9 instead of v1.9f) ;-)Best Regards, Thorsten. Quote Link to comment Share on other sites More sharing options...
stryd_one Posted November 7, 2007 Report Share Posted November 7, 2007 Wicked. Bring on the SID alarm clock! :) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.