Jump to content


  • Content Count

  • Joined

  • Last visited

Everything posted by trossin

  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
  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
  7. 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 ifd
  8. 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. 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 funct
  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
  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 turni
  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: unsi
  16. I finished up adding write support as well as date and time to my SD project this Spring and finally got it on the web recently. With this code, it is possible to read, write and delete files as well as created and remove directories on FAT file systems built on MMC, SD or SDHC cards using long filenames. The project can be found here: http://www.tedrossin.net46.net/Electronics/Pic/Pic.html#SDCardInterface This project uses the large memory model found in BoostC 7.xx. I should also mention that I developed this project with a custom SD card plugin that really helped ease develop
  17. If you don't care about the details of USB you can always go the FDTI route where it converts USB to serial or parallel or get a USB to TTL RS-232 cable:<br /><br />https://www.sparkfun.com/products/9716<br />https://www.sparkfun.com/products/9717<br /><br />
  18. I agree with Jorge that BoostC is the way to go. I also make my own libraries so I have just what I need. I tried C18 and found that it generated very bloated code compared to BoostC. Also, I needed to do a lot of typecasting and other ugly games to get it to use 8-bit variables correctly On a side note, I'm a big fan of the SourceBoost simulator and the ability to create custom plugins to emulate my external hardware (SD cards, NIXIE tubes, PWM motors, keypads and antique computers). This alone is worth the price of the tool and saves me a great deal of time and frustration developing pro
  19. SIN = (data >>loop) & 1; or SIN = (data & (1>>loop)) ? 1 : 0; Which ever produces the smallest code.
  20. I downloaded version 7.20 and found that my original case still fails. I did more experiments on version 7.20 and found that the problem only shows up if your code is assembled at a somewhat large address. When label1 is 0x0028, the results are correct. If I moved it out to 0x1964 by adding more code it fails. In this case, the end of case 1 did a positive branch (nearly max) instead of a negative branch back to label 1. I attached a simpler project to reproduce the failure. I should also mention that this project has some code commented out that crashes the compiler with an access
  21. I tried a simpler case with just a large while loop and found that the compiler/assembler correctly generated a GOTO. So the bug seems to only be with case statements. void main() { unsigned long a=0,b=1,c=2; while(1){ a = a + b + c; a = a + b + c; ... a = a + b + c; a = a + b + c; } } 10C0 5014 MOVF CompTempVar1002, W 10C2 6E04 MOVWF main_1_a+D'3' 10C4 EF12F000 GOTO label1 10C8 ; } main function end
  22. If I want to look at a variable named BootSectorCommon.FirstRootDirSecNum in the watch bar, I am out of luck as it is more than 25 characters. I was forced to rename my structure BSC in order to debug my program. In a perfect world it would be super fantastic if the watch bar understood structures and would allow me to expand them to see the fields (like Visual C++). This is all low priority stuff but if it is easy, it would be nice to have for us long variable name people.
  23. Bug description: If the label for a branch (BRA) is too far away, no error is generated but instead the distance is truncated resulting in a branch to a bogus location. Steps to reproduce: See below in comments. I also attached the project Expected behaviour: The assembler should have produced an error or better yet, the compiler/linker should have generated a goto instruction since it has a much larger range. Is the problem 100% reproduceable: This happens every time with this code. IDE version: 7.11 Compiler: BoostC Compiler version: "C:\Progra
  24. #define SECTOR_FETCH16(Index) (*(unsigned short *)&SectorBuf[index]) #define SECTOR_FETCH32(Index) (*(unsigned long *)&SectorBuf[index]) #define BUF_FETCH32(Buffer) (*(unsigned long *)Buffer) //(SectorBuf[Offset+3]<<24) | (SectorBuf[Offset+2]<<16) | (SectorBuf[Offset+1]<<8) | SectorBuf[Offset+0]) //(SectorBuf[Offset+1]<<8) | SectorBuf[Offset+0]) I used the macros above as they resulted in less code on an 18F part than the shifting method in the comments. I would think that JorgeF's technique would result in less/faster code than the shifting. I als
  • Create New...