Jump to content

trossin

Moderator
  • Content count

    243
  • Joined

  • Last visited

Community Reputation

0 Neutral

About trossin

  • Rank
    Super Enthusiast

Contact Methods

  • Website URL
    http://www.tedrossin.net46.net/index.html
  • ICQ
    0

Profile Information

  • Gender
    Male
  • Location
    Colorado

Recent Profile Visitors

924 profile views
  1. Just got burned again on an 18F2620: If I use: rom const char table[]= { ....}; it chews up RAM If I use: rom const char *table = {....}; it does not chew up RAM Using Version 7.22. It is bad enough that I have to break my tables up into tiny 256 byte pieces but until I found this secret, I was ready to go to the dark side (Microchip compiler).
  2. 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.
  3. 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.
  4. 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).
  5. 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.
  6. 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.
  7. trossin

    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.
  8. trossin

    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;
  9. 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);
  10. trossin

    Rom String Problem

    != '\0' is not needed with gcc
  11. 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
  12. 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. */ }
  13. 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!!!
  14. 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.
  15. 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.
×