Jump to content

Reynard

EstablishedMember
  • Content Count

    687
  • Joined

  • Last visited

Everything posted by Reynard

  1. Sure a nice feature. I still prefer to use the full variable name for clarity to which variable I am using. Sometime sizeof(struct) is nice to use. It all depends on your code and preference I suppose. You will be wanting anonymous unions inside structs next Cheers Reynard
  2. put your long into a union along with an array of 4 unsigned chars. union { unsigned long temp; unsigned char arTemp[4]; } longTime; longTime.temp=ON_time_secs; eeprom_write(store_day, longTime.arTemp[2]); eeprom_write(store_day+1, longTime.arTemp[1]); eeprom_write(store_day,+2 longTime.arTemp[0]); or something similar to this. Cheers Reynard
  3. If you have the same variable name in both structures (could happen if structures where similar in content) then you would have to name the structure you need anyway. Anonymous structures are not ANSI C are they ? but a Microsoft C extention. May not be allowed in C++. My thrupence worth. Reynard.
  4. There are several bits in the configuration bytes that are set to '0' for an erased device. I kind of agree that the compiler should respect the device default values and only change the bits that have been declare in the pragma. Cheers Reynard
  5. Yes you are correct, it goes into the Extra linker options: edit box. Your boot loader will contain a jump/goto to address 0x0800 to start your application. Reynard
  6. Well, the USB and USART are separate devices and use different pins on the chip, so the answer is Yes you can use them both at the same time. The down side is that you will probably have to erase your PIC and install your own USB driver. Something like the Ian Harris USB library, then use the Microsoft CDC driver thingy to communicate with a PC. You can write your own USB driver for the PC if you want maximum USB speed but that is a bit more complicated. It may well be possible to have two USB drivers installed, but I don't know how the ECIO bootloader allows you to add/delete/change interrupt hooks if at all. The bootloader may just poll the USB to leave the interrupts free for the user. The ECIO manual may have some clues. You can try posting questions about the ECIO boards on the Matrix Multimedia forum where you will get, I suspect, a more expert answer from experienced users. Food for thought. Reynard
  7. These are the configuration data for your PIC. Check out the header file for the details. #define _CONFIG1L 0x00300000 #define _CONFIG1H 0x00300001 #define _CONFIG2L 0x00300002 #define _CONFIG2H 0x00300003 #define _CONFIG3H 0x00300005 #define _CONFIG4L 0x00300006 #define _CONFIG5L 0x00300008 #define _CONFIG5H 0x00300009 #define _CONFIG6L 0x0030000A #define _CONFIG6H 0x0030000B #define _CONFIG7L 0x0030000C #define _CONFIG7H 0x0030000D Cheers Reynard
  8. Reynard

    Bit Access Bug...

    Definitely a bug. Workaround: set_bit(TxChar,9); or TxChar |= (1 << 9); seem to work. Cheers Reynard
  9. Have you tried the compiler switch -isrnoshadow to see if that helps. See page 24 of the BoostC manual. Cheers Reynard
  10. Mave you tried posting to the Matrix Multimedia forum. The makers may have more of an idea. Matrix Multimedia Web Site Cheers Reynard
  11. Hmm! Maybe MPLAB doesn't work correctly then. BoostC debugger says it works for porta bits 0-3 using your code. Cheers Reynard
  12. If you have no interrupt vectors defined in your code then the code space for them is free for the linker to put whatever it wants in that space. Put interrupt() and/or interrupt_low() into your code and things will change. Cheers Reynard
  13. Warren, Have you added in the BoostC library file into your project as described on page 20 of the manual. Cheers Reynard
  14. Hi Jorge, As Pavel says, if you turn on 'All Warnings' you would have gotten a warning informing of loss of data. You can use the command line setting or in the IDE use 'Settings -> Options...' then click All Warnings. The compiler demoted your value of 500 by truncating to the last 8 bits leaving you with 0xF4 or 244ms as you got. All Warnings is good for beginners as it can pick out simple unintended errors of loss of data etc. It is also useful for experienced programmers to run their code through the All Warnings occasionally. We all have senior moments. Cheers Reynard
  15. delay_ms only takes an unsigned char value therefore should be in the range 1 - 255. Page 69 of manual. To get 500ms call the delay_ms(250) twice. Cheers Reynard
  16. I don't quite know what your are saying about the leap year problem. Can you expand a little. int leapyear; int year; unsigned char four; four = 4; year = 2002; leapyear = year % four; This code comes up with a leapyear = 2 as expected. Cheers Reynard
  17. The compiler usually has good reason for letting out this warning message. Have you looked at the call tree to see if the function that calls your missing functions is there ? Do you have any 'if' statements that always evaluate to false ? i.e. if (1 == 2) comparing constant with constant. Do you have any '#if' directives that always evaluate to false ? Do you have any code that is unreachable from your main() function and descendents or interrupts. There will be a simple solution somewhere in your code I have no doubt. Regards Reynard Another idea: Do you have any infinite loops with code after them. i.e. for (; {...} while(1) {...} these are loop forevers therefore any code below them cannot be reached. Unless they have a 'break' inside them that is.
  18. Writing a bit on a port sometime depends upon the hardware attached to the port. Sometime you can write a '1' to a port bit, but when you read the port that bit can read as a '0' because the output pin voltage is less than the '1' threshold due to what is connected to the port pin. i.e. base of a transistor. To avoid Read-Modify-Write problems, I sometime use a shadow register in RAM. I do all my changes to the shadow register then do a write only to the port. If I need to know the state of an output pin I can refer to the shadow register which should reflect the port output. Updating the port can be done immediately after changing the shadow register or sometime I wait and write the shadow register to the port during a timer tick interrupt. This means there is only a single place for all the port writing. All depends on your application and hardware design really. set_bit(PORTC, 1); is basically a macro for PORTC.1 = 1; Cheers Reynard
  19. Yes, but what are they set to when the bootloader was installed ? Watchdog ON or watchdog OFF etc.
  20. So what are the configuration bits set to then Dave ? Does EZ Controller data sheet tell those with these controllers what they are. Reynard
  21. As part of your startup and configuration of the device, you should read the GPIO and reset any interrupt flags before you start your main process loop. The change register has to be set to match the initial input port values so you have to read the port to make the current value the old latched value. I hope that makes sense! Cheers Reynard
  22. Have you tried reading the GPIO ports before clearing the interrupt flag GPIF. The port has to be read to end the change mismatch condition otherwise GPIF will just set itself again (page 21 of data sheet). Cheers Reynard
  23. Dude, I am all out of ideas. I assume you have configured your motor controller for the correct device so I won't ask. The watchdog timer is ON by default, so turn it OFF in the CONFIG section while you are developing. Watchdog timers are nice to have in finished code just in case something does not quite go to plan in your software. Try doing a wrap-around on the controller to see if you can recieve what you sent and compare the data. i.e. putc, getc, compare, putc, getc, compare, etc. Cheers Reynard
  24. How do you know it is not sending a NULL character ? What does your receiving device do with a NULL character ? Cheers Reynard
  25. What! A forum that does not like '\' ? Doh! it just done it again. I will just try a few sneeky tests. '\','\\',''. Reynard Hmm! Interesting. Test was: backslash-0, backslash-backslash-0, backslash-0-0
×
×
  • Create New...