PropDNA+RTC Board and SimpleIDE
Because this board has a built in RTC and some expanded RAM, I am trying to see what I can do with it. The question I have is, I noticed that SimpleIDE comes with dna.cfg and dna-nway.cfg preloaded, why doesn't it come up as a selection for board type? What is dna-nway.cfg? What can I do to make that visible for selection? I do not remember seeing any instructions in the documentation.
Ray
Ray

Comments
Board Types on page 32 of the user guide mentions adding board types to boards.txt.
Look at the heading Special Clock Boards. Item 3 says:
Ray
Ray
You need to be admin to change the file.
The alternative is to copy the dna.cfg file to your project folder.
I am not sure if everybody is going to rush out and buy one of these boards, some reminders:
For the SD usage, when using Simple View - 'int DO = 0, CLK = 1, DI = 2, CS = 3' is needed to access the SD.
I tried doing a simple blinker program in CMM mode, DNA-NWAY Board Type, which worked as expected. I also tried doing the blinker in XMMC External Flash Code... DNA-NWAY, which also worked as expected. The one thing that got my attention was the Code Size, it stayed the same as the CMM mode. On the Activity Board when you switched to the XMMC... mode, the program size increased by a substantial amount, I was expecting to see the same thing with the DNA board. Is there an inconsistency with the Code Size reporting with the DNA board?
Back some time ago I wrote a program for accessing the RTC for this board, I will have to see if I still have the program somewhere, bring it up to today's standards, and see if it functions as expected in Simple View.
Ray
Thanks for your notes on the board.txt file.
XMMC is essentially stored as LMM with some extra code.
I'm not sure about dna.cfg -vs- dna-nway.cfg sizes. SimpleIDE just reads the fields generated by propellergcc.
Ray
In this program I also added SD support, and with that added in, and using the XMMC mode: Code Size 35,104 bytes (36,040 total). This is no problem because of the 1 megabyte flash ram, but I wonder if the program speed really starts to slow down when the program really gets big.
As for the RTC, on this board, I am still trying to figure out what is the best approach for resolving this issue.
Ray
Ray
Andy does not provide xmm-single and xmm-split libraries in Simple Libraries. You can't use them with just flash anyway.
Post your xmmc sd code please. I'll look at it this evening.
I found my original program for setting the clock for this board, and it is still working as expected considering it was develop well over a year ago, not sure what version of SimpleIDE I used. Now I have a starting point, the main RTC program, and the necessary I2C part. I noticed that there is a libsimplei2c in the Simple library; I believe I did a spin2cpp on Dave Hines version of I2C, wonder if simplei2c is a good substitute?
Ray
Which BoardType are you using for XMMC? DNA, DNA-HI, DNA-SQI, or DNA-SQIHI?
Also, where is your Flash Chip? U9 or U12?
Can you run any program at all like Welcome.side using XMMC?
I had no problems using the SDCard with XMMC on my DNA board.
It has this configuration:
- Quad SPI Flash in U12 next to XTAL
- SDCard on pins 16,17,18,19 - DO jump to P16, CLK to P17, etc...
- Use DNA:SQIHI board type
Ray
For your configuration, you need to use board type DNA:SQI (not DNA:SQIHI). I'll change my board and test this morning.
The solder bridges can be removed by heating them and tapping the board on a table on the reset button side. Cutting is not necessary.
In some ways this board is too flexible.
However apparently it doesn't matter if DNA:SQI or DNA:SQIHI is used - presumably because of the explicit sd_mount.
I would still choose DNA:SQI for the SD Card pins on 0,1,2,3 though.
Ray
I recommend however that you always close a file before reopening it. Your latest code doesn't.
Ray
//////////////////////////////////////////////////////////////////// /* Env_senseP.c December 10, 2013 */ #include "simpletools.h" #include "simpletext.h" #include "fdserial.h" #include "sRTC.h" #include "sht11.h" //////////////////////////////////////////////////////////////////// /* Auto sd_mount of SD. */ extern _Driver _NullDriver; extern _Driver _FileDriver; _Driver *_driverlist[] = { &_NullDriver, &_FileDriver, NULL }; //////////////////////////////////////////////////////////////////// serial *xbee; FILE *sp; //////////////////////////////////////////////////////////////////// static volatile float sht11_temp; static volatile float sht11_humid; static volatile int logstat; unsigned int sht11stack[40 + 25]; unsigned int sensestack[40 + 25]; //////////////////////////////////////////////////////////////////// int XB_remote(void); void test_SD(void); void get_Time(void); void get_TD(void); void menu(void); int prompttime(char *prompt); void set_Time(void); void set_Clock(void); void date_SD(void); void time_SD(void); void sht11(void* par); void senselog(void* par); //////////////////////////////////////////////////////////////////// int main() { // Add startup code here. /* Open a file for append. */ if((sp=fopen("SenseD.txt","a"))==0) { while(1) { high(27); // Red LED, error on open. pause(500); low(27); pause(500); } } else { high(26); // Green LED, file was opened. } /***********************************/ /* Start the sht11 cog. */ cogstart(&sht11, NULL, sht11stack, sizeof(sht11stack)); cogstart(&senselog, NULL, sensestack, sizeof(sensestack)); pause(100); /***********************************/ /* Init the XBee module. */ /* Rx Tx mode BAUD */ xbee = fdserial_open(25, 24, 0, 9600); pause(50); /***********************************/ /* Start the Sensirion RTC. */ sRTC_Start(); sRTC_Update(); sRTC_Set24hourmode(1); sRTC_Update(); /***********************************/ int xbcmd = -1; /***********************************/ /* Start up header. */ writeStr(xbee,"Environ Sense Program\n"); menu(); writeStr(xbee,"> "); while(1) { // Add main loop code here. xbcmd = XB_remote(); } } //////////////////////////////////////////////////////////////////// void menu() { writeStr(xbee,"Menu - help, time, date, onled, offled, \n"); writeStr(xbee," settime, setclock, temp, humid \n"); } //////////////////////////////////////////////////////////////////// int XB_remote() { char inBuff[40]; int retval = 0; if(fdserial_rxReady(xbee)) { readStr(xbee, inBuff, 40); if(!strcmp(inBuff, "onled")) high(27); // Red LED else if(!strcmp(inBuff, "offled")) low(27); // Red LED else if(!strcmp(inBuff, "write")) test_SD(); else if(!strcmp(inBuff, "time")) get_Time(); else if(!strcmp(inBuff, "date")) get_TD(); else if(!strcmp(inBuff, "help")) menu(); else if(!strcmp(inBuff, "settime")) { writeStr(xbee,"Hour,Minute,Second\n"); set_Time(); } else if(!strcmp(inBuff, "setclock")) { writeStr(xbee,"Month,Day,Year xx,dow,Hour,Minutes,Seconds\n"); writeStr(xbee,"dow: 0-Sun,1-Mon,2-Tue,3-Wed,4-Thu,5-Fri,6-Sat\n"); set_Clock(); } else if(!strcmp(inBuff, "temp")) { writeFloat(xbee,sht11_temp); writeStr(xbee,"\n"); } else if(!strcmp(inBuff, "humid")) { writeFloat(xbee,sht11_humid); writeStr(xbee,"\n"); } else if(!strcmp(inBuff, "testlog")) { logstat = 1; } else { writeLine(xbee,"Invalid Command!"); retval = -1; } writeStr(xbee,"> "); } return retval; } //////////////////////////////////////////////////////////////////// void test_SD(void) { char outBuff[] = {' ',' ',' ',' ',' ',' ',' ',' ','\r','\n'}; sp = fopen("SenseD.txt", "a"); fwrite("\r\n",1,2,sp); // CR date_SD(); // Write date fwrite(" ",1,2,sp); // CR time_SD(); // Write time fwrite(" ",1,2,sp); // CR sprint(outBuff,"%f",sht11_temp); fwrite(outBuff,1,8,sp); fwrite(" ",1,2,sp); // CR sprint(outBuff,"%f",sht11_humid); fwrite(outBuff,1,8,sp); fclose(sp); } void date_SD(void) { char outBuff[] = {' ',' '}; int day, month, year; sRTC_Update(); month = sRTC_Getmonth(); day = sRTC_Getday(); year = sRTC_Getyear(); sprint(outBuff,"%d",month); fwrite(outBuff,1,2,sp); fwrite("/",1,1,sp); sprint(outBuff,"%d",day); fwrite(outBuff,1,2,sp); fwrite("/",1,1,sp); sprint(outBuff,"%d",year); fwrite(outBuff,1,2,sp); } void time_SD(void) { char outBuff[] = {' ',' '}; int hour, minute, second; sRTC_Update(); hour = sRTC_Gethour(); minute = sRTC_Getminutes(); second = sRTC_Getseconds(); sprint(outBuff,"%d",hour); fwrite(outBuff,1,2,sp); fwrite("/",1,1,sp); sprint(outBuff,"%d",minute); fwrite(outBuff,1,2,sp); fwrite("/",1,1,sp); sprint(outBuff,"%d",second); fwrite(outBuff,1,2,sp); } //////////////////////////////////////////////////////////////////// void get_Time(void) { int result, result1, result2; sRTC_Update(); result = sRTC_Gethour(); result1 = sRTC_Getminutes(); result2 = sRTC_Getseconds(); writeDecDigits(xbee,result,2); writeStr(xbee,":"); writeDecDigits(xbee,result1,2); writeStr(xbee,":"); writeDecDigits(xbee,result2,2); writeStr(xbee,"\n"); } //////////////////////////////////////////////////////////////////// void get_TD(void) { int result, result1, result2; sRTC_Update(); result = sRTC_Getmonth(); result1 = sRTC_Getday(); result2 = sRTC_Getyear(); writeDecDigits(xbee,result,2); writeStr(xbee,"/"); writeDecDigits(xbee,result1,2); writeStr(xbee,"/"); writeDecDigits(xbee,result2,2); writeStr(xbee,"\n"); } //////////////////////////////////////////////////////////////////// int prompttime(char *prompt) { int rc = 0; char *endp; char buffer[10]; do { writeStr(xbee,"Enter "); writeStr(xbee,prompt); writeStr(xbee," "); readStr(xbee,buffer,10); rc = strtol(buffer, &endp, 10); if(endp == buffer) { if('\n' == *endp) { rc = 0; break; } writeStr(xbee,"Invalid entry"); writeChar(xbee,*endp); writeStr(xbee,"...."); writeStr(xbee," Please enter a number.\n"); } } while(endp == 10); return rc; } //////////////////////////////////////////////////////////////////// void set_Time() { int hour,minute,second; hour = prompttime("Hour"); minute = prompttime("Minute"); second = prompttime("Second"); writeDec(xbee,hour); writeStr(xbee,":"); writeDec(xbee,minute); writeStr(xbee,":"); writeDec(xbee,second); sRTC_Settime(hour,minute,second); sRTC_Update(); writeStr(xbee,"\n"); } //////////////////////////////////////////////////////////////////// void set_Clock() { int month,day,year,dow,hour,minute,second; month = prompttime("Month"); day = prompttime("Day"); year = prompttime("Year"); dow = prompttime("DayOfWeek"); hour = prompttime("Hour"); minute = prompttime("Minute"); second = prompttime("Second"); writeStr(xbee,"\n"); writeDec(xbee,month); writeStr(xbee," "); writeDec(xbee,day); writeStr(xbee," "); writeDec(xbee,year); writeStr(xbee," "); writeDec(xbee,dow); writeStr(xbee," "); writeDec(xbee,hour); writeStr(xbee," "); writeDec(xbee,minute); writeStr(xbee," "); writeDec(xbee,second); writeStr(xbee," "); writeStr(xbee,"\n"); sRTC_Setdatetime(month,day,year,dow,hour,minute,second); sRTC_Update(); } //////////////////////////////////////////////////////////////////// /* Cog function. */ void sht11(void* par) { /***********************************/ /* data clk */ sht11_pins(17, 16); while(1) { /* Raw temp */ int soT = sht11_tempRaw(); //print("soT=%d", soT); /* Raw real humidity */ int soRH = sht11_rhRaw(); //print(" soRH=%d", soRH); /* Degrees C */ float sTC = sht11_degC(); //print(" sTC=%f",sTC); /* Degrees F */ float sTf = sht11_degF(); sht11_temp = sTf; //print(" sTf=%f", sTf); // sprint(outBuff,"%f",sTf); // fwrite(outBuff,1,8,sp); // fwrite("F ",1,2,sp); /* Raw humidity Linear */ float sRHL = sht11_rhLinear(); // print(" sRHL=%f", sRHL); /* Raw humidity True */ float sRHT = sht11_rhTrue(); sht11_humid = sRHT; //print(" sRHT=%f\n", sRHT); // sprint(outBuff,"%f",sRHT); // fwrite(outBuff,1,8,sp); // fwrite("H\r\n",1,3,sp); /* Dew point C */ float sDPC = sht11_dewPointC(); //print(" sDPC=%f\n", sDPC); sleep(200); } } //////////////////////////////////////////////////////////////////// /* Cog function. */ void senselog(void* par) { high(27); // Red LED pause(50); low(26); // Green LED while(1) { //sostat = logstat; //if(logstat == 1) //{ //low(26); //} pause(250); } }Eric
I think I had a similar problem that I was working on, but it never got resolved, so this is not my first encounter. I tried replicating the problem in a smaller program, but the problem only shows up in the larger program, maybe it is a lack of available memory, but I have no way too confirm that. If that is the case, the subtlety of this, is kind of alarming.
Ray
while(1) { sostat = logstat; if(sostat == 1) { low(26); } pause(250); }In this scenario, I would change the 'static volatile int logstat' variable, in the main COG IO from 0 to 1, and have the logic work as expected. But, I get the feeling that it can not be accomplished, according to what you just stated. I guess I need some more definition as to what you can really do to another COG from within the main COG. I am really looking for a way to do some controlled tasks in a COG that is controlled by the main COG without having an affect on the main COG IO system. I hope this makes sense?Ray
I was also thinking that I might have a better chance of success of this idea using threads, but I think that would even be more complicated than trying to deal with COGs. But, I am not absolutely sure about this.
Ray
The easy rule is: do not try to use the same pin from 2 different COGs.
Ray
/* COG function. */ void senselog(void* par) { int sostat; while(1) { sostat = logstat; if(sostat == 1) { sp = fopen("SenseD.txt", "a"); //date_SD(); char outBuff[] = {' ',' '}; int day, month, year; sRTC_Update(); month = sRTC_Getmonth(); sprint(outBuff,"%d",month); fwrite(outBuff,1,2,sp); fwrite("/",1,1,sp); fclose(sp); logstat = 0; } pause(250); } }Why not just do this?
else if(!strcmp(inBuff, "testlog")) { logstat = 1; pause(2000); high(27); }I guess this is where it is locking up. When I do the 'testlog' command, the senselog COG does it thing, I get a two second pause before the high(27) red LED turns on, and then terminal screen does not go to the expected '> ' , the terminal screen is no longer responding to a key press. For some reason it is unable too continue with the loop, or something in the main COG has been affected. Since the senselog COG is functioning as expected, is the stack appropriation having an affect on the main COG?Ray
Ray