Jump to content

Reynard

EstablishedMember
  • Content Count

    688
  • Joined

  • Last visited

Everything posted by Reynard

  1. Hi Tom, A 4 digit 7 Seg LED already exist in the IDE plugins list and seems to work well for me using multiplexed outputs. Cheers Reynard
  2. If you read the section "MPLAB Intergration" in the C++ manual it explains all you need to use SourceBoost within MPLAB and how to include libraries into your project. Have you tried using the SB IDE instead of MPLAB to get your project off the ground and gain more experience. Cheers Reynard
  3. Try it this way: typedef struct { double set_point; // Desidered Value double proportion; // Proportional Const double integral; // Integral Const double derivative; // Derivative Const double last_error; // Error[-1] double prev_error; // Error[-2] double sum_error; // Sums of Errors } PID; PID pid; void pid_init(PID *pp); void main() { pid_init(&pid); } void pid_init(PID *pp) { memset((void *)pp,0,sizeof(PID)); } Don't declare your variables using the typedef. "double" is not a valid data type even if SourceBoost accepts it. SB will allocate space for a long.
  4. Try adding a cast to void. memset((void *)pp,0,sizeof(PID)); Cheers Reynard
  5. This is small fry stuff for V7.0 For PIC12 and PIC16 devices that have a SFR common to all banks, such as INTCON. Could it not do a bank selection change, setting/resetting of RP bits, and squeeze out that redundant instruction. if (intcon.T0IF && intcon.T0IE) 002B 1283 BCF STATUS, RP0 *** Not required instruction. 002C 1D0B BTFSS gbl_intcon,2 002D 2830 GOTO label3 002E 1E8B BTFSS gbl_intcon,5 002F 2830 GOTO label3 Other compilers don't put it in. Cheers Reynard Title should read SFR. Silly keyboard
  6. I rolled back to 6.95 yesterday and it works in that as well. Send in your files for Dave and Pavel to look at. Cheers Reynard
  7. The 628 has comparator (analogue) functions on RA0,1,2,3 pins which are enabled at POR. If you want digital I/O on these pins the you have to disable the camparator using the CMCON register. Program the CMCON register = 0x07 to disable the comparator and make the pins digital. Set the TRISA and TRISB as normal for inputs or outputs. Cheers Reynard
  8. When I have the text cursor showing in an edit window (Tabbed Window), then switch to another application like Acrobat to look at a data sheet, then switch back to the IDE, the text cursor is missing from the edit window and is sitting in the "Code" pane Assembly window. Can the window focus be restored to where it was left please. Cheers Reynard
  9. Hi Henry, You have to keep up with the fast changing face of BoostC. I do have the latest version but the code snippet I used was from the PIC16 section as you did not specify the PIC number you are using. Unless it is something complex like USB I always write my own libraries. That way they do what I want and I know exactly what makes them tick. If they don't work then I know who to blame. Cheers Reynard
  10. Hi Tom, You have to be careful how Microchip specify ROM size as they count it in terms of bits. 2048 code words at 14 bits per code word divided by 8 bits/byte gives you 3584 bytes or 3.5k. Confusing Eh ! Cheers Reynard
  11. Hi Henry, Looking at the eeprom.h file unsigned char eeprom_read( unsigned char address ); void eeprom_write( unsigned char address, unsigned char data ); it shows the address as an unsigned char therefore giving a max address of 255. Using the functions are shown in the manual and are straight forward. For simple stuff like reading/writing eeprom I always do my own thing, that way I can read/write blocks and have it all interrupt driven. Cheers Reynard
  12. You can't always do relative to the project directory. I just added a file using the "add file" method and it put it into the project window as absolute. This is probably due to the file I added was on another disc drive. Cheers Reynard
  13. Hi Phil, Good to see that you have found a solution. I do a similar thing using an X/Y accelerometer on its side as an inclinometer for my field archery. I use the stack method I mentioned earlier. Time and code space is not a problem for me. I use a lookup table to convert the average X channel in to degrees then put it onto a small 2 digit LED display. It is all build into a long plastic box (120x30x30mm) with a hole at each end to look through and pick out my target. The display is inside the box under the front hole so I can get an immediate reading while still looking at the tar
  14. Ian, You have to follow the instruction address sequence and not the sequence the instructions are listed. Always look at the .lst file and not the .asm file when reading assembler output. Cheers Reynard
  15. No warning eh! It gave me one when DRAW_TOTAL_BUFFER_SIZE set to 504. You could just sneak in a little cast for the loop compare. for(count = 0; (int)count < sizeof(draw_buffer0); count++) { draw_buffer0[count] = 0; } Cheers Reynard On second thought no you can't it is still a char. Stupid me.
  16. Hi Ian, Turn ON all warnings and the compiler will issue a warning. You have an infinite FOR loop as count will always be < 256 for a 256 byte array as it is a unsigned char (as David indicates). Infinite loops don't need a return instruction. Smart compiler Cheers Reynard
  17. Hi Phil, Dividing signed ints by powers of 2 requires special treatment and fudge factors because of rounding problems. I suggest converting the negative int to a positive value then dividing by 8 then make negative again. BoostC is not the only compiler that gets this one wrong for signed variables. Cheers Reynard
  18. Hi Phil, You seem to be on right track for getting that code efficiency up. Memmove and memcpy are standard library functions and not op-codes. Writing your own version for your application would probably be more efficient and quicker. To shift signed ints just use a C statement. The code produced will probably be as good as you can write and takes care of the signd and carrys. The compiler may on occasion use FSR0 inside build in and library functions so keep an eye on that as called functions may not preserve it. The interrupt preserves FSR0. When using FOR loops, it i
  19. Hi Phil, Arrays will be put where the linker thinks there is space. If you assign a fixed address to your arrays then you can put them into the same page. Any variables you use to manipulate these arrays, fix them into the same page as the arrays to reduce some page switching code. Instead of treating your arrays as circular buffers and testing for pointer wraparound, consider using the arrays as a stack. Use something like memmove or memcpy (or assembler equiv) to shift everything up an int then insert your new sample into the first array location only. Declare unsigned int arr
  20. Have you checked VREGEN in CONFIG2L to see if it is enabled ? Cheers Reynard
  21. Ian, I think what you have said is completely correct. Saying that, BoostC does not conform to the rules of K&R, ANSI C, C99 etc. and contains addition features of C++ such as reference variables and function overloading. I think it is good practice to have only a single variable (or FSR) assignment per statement. The user can be confused as to the operation of the compiler/optimiser when he sees something like this: porta = portb = 0; 007C 6A81 CLRF gbl_portb 007E 0E00 MOVLW 0x00 0080 6A80 CLRF gbl_porta Ignoring the redundant movlw instruction, both
  22. Hi Shree, I got my EasyPIC5 a few months ago to replace my tired EasyPIC2 and I was also curious about the small touch screen that they have so I had to get one to play with. Simulator generally run a software simulation of a PIC using your program. They are useful for testing the operation of function that do calculations and conversion etc but can be a pain in the butt when you need to provide I/O stimulation that mimics you actual application. You can use plug-ins and stimulus scripts if you have the time and patience to write them. Emulators (in-circuit) are sometimes special
  23. There is more than one way to skin at cat and I doubt if any of them is the correct way. You should initialise the important registers, but what are the important register ? Port A supports several peripherals like ADC, USB, timer input etc. Should you initialise all of them just to make sure they are in the correct state. The example is just that. An example. It is not the definitive method of initialising Port A. I am sure the OP will use the appropriate method of interfacing his switches depending on the final application. Cheers Reynard
  24. Hi Ian, Well, you have to read and believe the manual at some point. You cannot initialise every register in a PIC of this size just in case the RESET did not do what it said it would in the manual. Some PICs do have an errata sheet as long as your arm which is sad, but they should also be read along with the manual. As for the switches; I don't know how they are wired up. Do they just short to ground, do they switch between 0V and +5V using SPDT, do they come through some logic such as RS flip-flop for debouncing etc. etc. I use an EasyPIC5 board when I am playing around wit
  25. Ah! Yes But, No But ! CMCON is set to 0x07 on RESET dude. Cheers Reynard
×
×
  • Create New...