Jump to content

gviaud

EstablishedMember
  • Content Count

    17
  • Joined

  • Last visited

Community Reputation

0 Neutral

About gviaud

  • Rank
    Newbrie
  1. I am attempting to port some code from C18 to BOOSTC for use with USB and CDC for RS-232 Emulation and am having some serious trouble when it comes to typedef unions - maybe someone here can help me out (my programming skills are medioker at best.. help appreciated) please see the code below - try to put it in some of your code and build. typedef union _BD_STAT { char _byte; struct{ unsigned BC8:1; unsigned BC9:1; unsigned BSTALL:1; //Buffer Stall Enable unsigned DTSEN:1; //Data Toggle Synch Enable unsigned INCDIS:1; //Address Increment Disable unsigned KEN:1; //BD Keep Enable unsigned DTS:1; //Data Toggle Synch Value unsigned UOWN:1; //USB Ownership }; struct{ unsigned BC8:1; unsigned BC9:1; unsigned PID0:1; unsigned PID1:1; unsigned PID2:1; unsigned PID3:1; unsigned :1; unsigned UOWN:1; }; struct{ unsigned :2; unsigned PID:4; //Packet Identifier unsigned :2; }; } BD_STAT; //Buffer Descriptor Status Register Thanks, George
  2. Is there any way to force this type of function to be inline or macro'd? Would this help prevent problems like this in the interrupt routine? I have some stuff in my interrupt routine that requires 16 and 32 bit math division and multiplication... Help :angry: George
  3. I am having a similar problem. When I attempt to include some I2C code from another path I get the same error. When I use relative paths ("..\..\etc\wherever\etc.h") the code compiles but then gives me an error "FATAL: Don't know how to make ..\..\etc\wherever\etc.obj" " Did you guys come up with a solution? Pavel - let me know if you would like to see a copy of the project and includes Thanks, George
  4. Thank you for the information - I will look into the 18F family. Due to the time-critical nature of my code, I will not be able to easily implement the WDT unless I can turn it on when I want to reset the MCU so I don't have to continuously zero the timer- I don't think this is possible but it may be (anyone?) You mentioned "doing it manually" - How can I do this? (What is the instruction pointer in the 16F family? Just set this to 0000? Thank you for your time and assistance. Regards, George The 16F87x do not have a reset instruction unlike the 18F25x/45x equivalent. So you either have to manually do this or you could use the WDT. To use the WDT your application must periodically reset the timer to stop the timer resetting the CPU. Then when you actually want to reset the CPU you stop resetting the WDT. However the best way is to migrate to the 18F family. Better CPU, more RAM, more ROM, more peripheral, faster and and the same price point. <{POST_SNAPBACK}>
  5. Anyone know how to force a reset with code on a 16F87x? I would like to get the chip back to a POR state... if possible... without hardware Thanks, George
  6. UPDATE - UPDATE - UPDATE I figured out what was wrong with this code (recently purchased BoostC and was forced to correct this problem...) I declared my variables as short and they SHOULD have been declared as unsigned short. If you wish to see the OLD code fail, calculate sqrt(34000) or some other high value. The var_in becomes NEGATIVE and messes up the works. defining everything as unsigned short solves the problem. All is well with my world - thanks to all of the forum junkies for the help they gave me without knowing it as I read their words of wisdom. George
  7. I wrote some code to output a char * to my serial port. Here is a snip: const char *test = "This is test data"; for (x = 0; x < sizeof(test); x++) { Send_232(test[x]); } Output from this code is "Th" If I do this: for (x = 0; x < 17; x++) { Send_232(test[x]); } everything works... I get the feeling sizeof(test) is returning 2... any idea why? Help! Thanks, George
  8. I am attempting to use PORTD on a 16F877 as standard I/O but am having trouble. My desire is to have all of the pins for port D used as an output. Each of the pins on PORTD on my hardware are tied to 10K resistors which are in turn each tied to VCC. For some reason, the pin never goes low on my oscilloscope! Reading the datasheet, there may be something I need to do with porte or trise first, but I'm not sure. Hope someone else knows how to do this easily and can help... Thanks This is all I am doing in code: trisd = 00000000b; while(1) { portd = 0; delay_ms(100); portd = 255; delay_ms(100); } Thanks, George
  9. The following code works perfectly in C2C Plus but has appears to have computational errors in boostc make a loop that increments a short by 1 and feed it into this function. Somewhere in the upper range of 16bit vars the resultant goes crazy jumping all over the place. I plotted the output using a DAC onto an oscilloscope to graph it - I dunno how you will get the output... (btw the dac code has been checked vs a looping 0-255 and works flawlessly). I have not bothered to look deeper into how or why this is happening as I am on a deadline and c2c plus compiles this into working code. I hope this helps and I haven't simply done something wrong. btw - feel free to use this code if you find it useful - the Babylonians liked it thousands of years ago :-) -George char sqrt(short var_in) { // Babylonian approximation square root algorithm // Note: Not optimized. Also, answer is truncated (no decimal section - 16bits!) short guess = 128; short gTemp; for (loop = 0; loop < 5; loop++) // run for 5 itterations (more than close enough) { //guess = ((var_in / guess) + guess) / 2; gTemp = var_in / guess; gTemp = gTemp + guess; gTemp = gTemp / 2; guess = gTemp; } return guess; }
  10. Has anyone had any spontaneous restarts occur when using char pointers with this MCU and C2C?
  11. I am getting all sorts of warnings with the SX-Key stock assembler and SASM (Page warnings etc)... I think this may be causing problems in my code. Can someone please help me by telling me what assembler I should be using and with what DEVICE directives etc. for C2C generated ASM to assemble correctly? My target is a SX28AC. Thanks, George
  12. I am not sure if this is a problem or not but much of the code I compile with C2C for a SX28 target causes Warning 48s (File Register Not in Current Bank) all over the place. Is this really a problem? My code seems to be doing odd things and I am not sure if this is the cause... Anyone have any experience on setting up C2C for SX28AC target? Anything special I have to do to make the code compatible with SASM? Help! Project due very soon... code is massive, no time to port to another assembler and no way can I do it in ASM with my current skill-set... Thanks, George
  13. I am trying to observe only the one byte of a 16bit variable and use it as a 16bit variable. I have created a 16Bit variable at a specific address and an 8bit variable at the same address. I have a feeling that it is being treated by the compiler as a 16bit variable, though. Example: short var16@20; char var8@20; will var8 be treated as var16 because it has the same address? Not sure how this compiles out... Thanks, George
  14. I am writing some very time-critical code (all loops must execute in the same amount of the all the time) and am using 16bit variables. I am noticing diferentials in the loops and think this is due to the 16bit math and logic. Does anyone know if the 16bit math takes different amounts of time depending on carry or not etc? Also, does the 16bit logic take different amounts of time? I dread writing my own 16bit math and logic but will do so if I must. Thanks, George
  15. I am having trouble with an SX28 target trying to get the internal pullups to enable/disable in conjunction with code to set the port direction. Can someone provide me with some sample code to do this for portA, portB and portC? I think this would be useful code for all (I know I will find it invaluable!) Thanks. George
×
×
  • Create New...