Jump to content


  • Content count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About trossin

  • Rank
    Super Enthusiast

Contact Methods

  • Website URL
  • ICQ

Profile Information

  • Gender
  • Location

Recent Profile Visitors

706 profile views
  1. I posted few new projects here (try Chrome if the pictures don't show up) : https://www.sites.google.com/site/tedrossin/home/electronics/pic There are a couple videos of a Lynx Motion AL5D robot arm being driven by a single PIC which controls the servos and walks the spline by doing some math on the fly. The PC just sends the spline parameters and a step rate to get from the current position to the next position. The PIC has a little software FIFO so that the PC is a few positions (key frames) ahead. The PC and PIC handshake for FIFO space to allow playing long sequences. The second video and screen shot of the editor show a sequence with 33 keyframes to move a ball and USB drive around on a table.
  2. Most PIC processors do not have hardware divide logic so division is done in software. It is up to the compiler to decide to implement exception handling or not. Since code space is usually a premium, I would expect that BoostC does nothing but give you a bad answer. For most tiny embedded processors, you will have to check your inputs and handle divide by zero yourself so that you can handle it the way that is best for your application.
  3. Click the Help menu on the SourceBoost IDE then select Plugin Description for details. I also have some examples I wrote here: https://www.sites.google.com/site/tedrossin/. Go to Electronics then PIC. The plugin examples are at the end of the list in the contents section(current #22).
  4. p += p->size; is the complaint.<br /><br />You might try helping the compiler out by doing some type casting.<br /><br />Also, I think SourceBoostC comes with a malloc library that you could use.
  5. My free website has been down for a good amount of time so I moved it here: https://www.sites.google.com/site/tedrossin/ I added a few new PIC projects (Wii Nunchuck interface using an 18F1330, TV speaker auto on/off and a stepper motor controller). I also have a servo control project I'm working on which uses spline interpolation of key frame values. I'm still working on the keyframe editor but it seems good enough for now. Here is a little video of it controlling a Lynxmotion robot arm: https://youtu.be/-VRBuqs75ZM?list=UUUQfBC8Ejgx7KjH8ehWmz1Q I'll post the schematic and code soon.
  6. Sourceboost Dead?

    SourceBoost runs fine on Windows 8 and Windows 8.1 and makes super code. MPLABX also runs fine on Windows 8.1 and the C compiler is free, supports floating point natively and variable args for printf. The catch is that it only is free for 18F processors and the code produced is not as small and fast as SourceBoost (for a large sum of money it will produce better code). The free Microchip compiler does not support the same function with different parameters like SB does nor does it have the lovely plugins and ability to write custom plugins for simulation. It is possible with some ifdefs to use common code that compiles on both tools.
  7. Variable Storage

    Why do the variables have to be together? The following code pieces can shift a 40 bit variable left or right by one bit and shift in the input Input. The 40 bit variable in Verilog speak is {High[31:0],Low[7:0]}. unsigned long High; unsigned char Low,Carry; unsigned char Input; // Shift Left Carry = (Low & 0x80) ? 1 : 0; High = (High<<1) | Carry; Low = (Low<<1) | Input; // Shift Right Carry = (High & 1) ? 0x80 : 0; High = (High>>1) | (Input ? 0x80000000 : 0); Low = (Low>>1) | Carry;
  8. The backslashes are continuation markers. #defines have to be on a single line. To avoid ugly definitions, C compilers allow the backslash to continue the current line on the previous line. #define ICKY you_are(\ int making_me_very_happy); Is the same as: #define ICKY you_are(int making_me_very_happy);
  9. Rom String Problem

    != '\0' is not needed with gcc
  10. Bug description: In the code below, the "ratio = (x==0) ? 0xffff : BigY/BigX;" returns the result of division the previous time this function was called when fixed_x is set to zero (which makes x 0). I attached a simple project which demonstrates the failure. I am able to work around this bug with an extra if statement "if(fixed_x==0) ratio = 0xffff;". Also, I still get the failure if I swap x for fixed_x in the original case. The code produced fails in the simulator as well as on Silicon (18F2620). It also fails with large and small memory models. In the simple example, the main function makes two calls to FixedAtan2 with different values but the second call gets the result of the first call which is -49.7 degrees instead of -90.0 degrees. int FixedAtan2(int fixed_y,int fixed_x) // Value returned is in 9.7 fixed point format. { unsigned int x,y; unsigned int Above,Below,Frac; unsigned int ratio; int angle; unsigned char NegX,NegY; unsigned char TableIndex,Half; unsigned long BigY,BigX; if(fixed_x<0){ NegX=1; x = -fixed_x; } else{ NegX=0; x = fixed_x; } if(fixed_y<0){ NegY=1; y = -fixed_y; } else{ NegY=0; y = fixed_y; } BigX = x; BigY = (unsigned long)y<<8; ratio = (x==0) ? 0xffff : BigY/BigX; // Work around for complier bug //if(fixed_x==0) ratio = 0xffff; Steps to reproduce:Build the attached projects and run to the while(1) in main. You will see AngleAboutX and AngleAboutY be the same values. If you single step into the second call, you can see the ratio equation produce the wrong answer. Expected behaviour: AngleAboutY should return 0xd300 which is -90.0 in 9.7 fixed point format. Is the problem 100% reproduceable: Yes. If fails every time. IDE version: 7.22 Compiler: Compiler BoostC Compiler version: 7.22 Target device: PIC18F2620 OS: Windows 7 and Windows 8.1 CBWiiNunchuckFail.zip
  11. Is it possible to get sprint with variable arguments or support variable arguments in general like the following? void HeaderPrintf(char *Format, ...) { va_list Marker; char Buffer[50]; va_start(Marker,Format); /* Initialize variable arguments. */ vsprintf(Buffer,Format,Marker); va_end(Marker); /* Reset variable arguments. */ }
  12. Below is assembly code that I use in my boot loader for 18F parts. The full project can be found here: http://www.tedrossin.net46.net/Electronics/Pic/Pic.html Scroll down and click on Serial Port PIC Boot Programmer. I would think you could convert this to C code without much work but the problem is determining what are valid blocks to write. I hope this helps. ; ************************************************************************ ; ** CmdEraseFlashRow: Get High address then low address and erase the ** ; ** row of 64 bytes. Bits 6:0 of the address are ** ; ** ignored. 0 is returned to signal the operation ** ; ** has finished. ** ; ************************************************************************ CmdEraseFlashRow: clrf TBLPTRU ; address of the memory block call GetRS232Byte ; Fetch high address[15:8] movwf TBLPTRH call GetRS232Byte ; Fetch low address[7:6] [5:0] are ignored movwf TBLPTRL bsf EECON1, EEPGD ; point to Flash program memory bcf EECON1, CFGS ; access Flash program memory bsf EECON1, WREN ; enable write to memory bsf EECON1, FREE ; enable Row Erase operation ; bcf INTCON, GIE ; disable interrupts movlw 0x55 movwf EECON2 ; write 55h movlw 0xaa movwf EECON2 ; write 0AAh bsf EECON1, WR ; start erase (CPU stall) ; bsf INTCON, GIE ; re-enable interrupts bra CleanExit ; ************************************************************************ ; ** CmdWriteFlashRow: Get High address then low address and 64 bytes ** ; ** of data and write flash memory. Bits 6:0 of the ** ; ** address are ignored. 0 is returned to signal the ** ; ** operation has finished. ** ; ************************************************************************ CmdWriteFlashRow: clrf TBLPTRU ; address of the memory block call GetRS232Byte ; Fetch high address[15:8] movwf TBLPTRH call GetRS232Byte ; Fetch low address some bit should not be set movwf TBLPTRL ; Write data to internal flash buffer movlw WRITE_BLOCK_SIZE movwf Tmp CmdWriteFlashRowLoop: call GetRS232Byte ; Get data to write movwf TABLAT ; present data to table latch TBLWT*+ ; write data, perform a short write ; to internal TBLWT holding register. decfsz Tmp bra CmdWriteFlashRowLoop TBLRD*- ; Point back to original row ; Write internal buffer to flash memory bsf EECON1, EEPGD ; point to Flash program memory bcf EECON1, CFGS ; access Flash program memory bsf EECON1, WREN ; enable write to memory ; bcf INTCON, GIE ; disable interrupts movlw 55h movwf EECON2 ; write 55h movlw 0AAh movwf EECON2 ; write 0AAh bsf EECON1, WR ; start program (CPU stall) ; bsf INTCON, GIE ; re-enable interrupts bcf EECON1, WREN ; disable write to memory bra CleanExi P.S. It only took 5 tries to get this to post correctly!!!
  13. OK. This one is a bit more intense than my CheapLA version because it uses a couple Xilinx CPLDs and external RAM but the PIC code shows examples of how to use the synchronous SPI interface to talk to the CPLDs and how to change the RS-232 baud rate on the fly when using faster serial cables. Code to control the timer output (to produce a 100Hz to 2.5 MHz clock) is also included. The project files and schematic can be found here: http://www.tedrossin.net46.net/Electronics/Xilinx/Xilinx.html#LogicAnalyzer2 P.S. I also updated the cheap logic analyzer to work with 3.3V logic by turning off the on-die pull ups and using external pull downs to ground. There is a link to the cheap version at the location given above.
  14. I think you are not being nice to the compiler as it has no idea the dimensions of your array. It thinks you just passed a 1D array when you in fact passed a 2D array. Maybe try: void Init (unsigned char myMATRIX[][16]) { to let it know that it is a 2D array where the smallest index is 16. This way the compiler can calculate the offsets properly. If this does not work, maybe skip passing a pointer to MATRIX and just use the global variable inside your routine.
  15. I have a boot loader that I wrote in assembler that just fits in the last 0x180 bytes of flash starting at location 0xfe80. I would like to include this in some C code projects but I know the inline assembly messes with the code so I just want to toss a bunch of hex constants into the hex file for programming. I tried the technique below and was able to simulate correctly but when I look at the .hex file, there is no 01020304 string in the file. rom unsigned char BootCode[256] @ 0xf000 = {1,2,3,4}; When I tried this technique, I did see entries in the hex file at 0xf010: unsigned char foo1() @ 0xf010 { return(5); } Is there a secret to get the first version to work? Now that I think about it, I could just burn up a bit more space and just implement functions to erase, write and read a block of flash along with a little interpreter for the serial port and just shove it at the end of my code space using the foo1 function trick. What I would like is a way for my little application to be able to have its firmware updated without using bootmode pins or doing a multi-step program of the part. I have a nice clean way to do this for pure assembly programs but would like to do this as a single hunk of C. So, I guess never mind except it would be nice to figure out how to park some constants at a specific location. I also tried putting the following in the function instead of return(5): asm data 0x01,0x02,0x03,004 And did get my bytes in flash memory. The only problem is that they are converted to 16 bit values and a line feed was added to the end: :0CF01000010002000300040005001200D3 :0C says 12 bytes F010 says starting at address 0xf010 00 says the type 0100 is a 16 bit low byte first 1 0200 is a 16 bit low byte first 2 0300 is a 16 bit low byte first 3 0400 is a 16 bit low byte first 4 0500 is a 16 bit low byte first 5 1200 is a 16 bit low byte first 0x12 (Line feed) D3 is the sumcheck value. Using 16-bit constants for asm data allows all the bytes to be written but with the order swapped and still gives the extra line feed. asm data 0x0123,0x4567,0x89ab :08F0100023016745AB891200E2 I also tried "Hello" like the user manual says but the string is ignored. asm data "Hello" results in a syntax error. asm data 1,2,"Hello" drops the hello.