Jump to content

Picxie

Moderator
  • Content Count

    277
  • Joined

  • Last visited

Everything posted by Picxie

  1. That is because C books assume that your program is going to run on a computer with an operating system, in which case main returns to the operating system. Most OSs expect main to return an error code ie 0 is ok. In a small embedded system there is no OS, the proceesor jumps to the reset vector on power up (or reset), Boost C puts a command at the reset vector to jump to start up code, when start up code completes it jumps to main.
  2. main() occurs in the root of the call tree, ie all functions are processed via PIC call instructions except main because it is the first function. Using the return command causes the compiler to generate a retlw instruction, the PIC debugger tries to execute retlw by extracting the return adrress off the function stack but there is no return address for main. Dont terminate main with return! you would be better stopping main with an endless loop. eg while(1);
  3. // to set as input leaving all other bits undisturbed bit_set(trisa,4); // to set as output bit_clear(trisa,4); OR #define BIT_4_MASK 0x10 // ie 0b0001000 #define BIT_1_MASK 0x1 // ie 0b00000001 // to set as input leaving all other bits undisturbed trisa |= BIT_4_MASK; // to set as output trisa &= ~BIT_4_MASK; // and to flip to the opposite state trisa ^= BIT_4_MASK; the bit functions are good for single bits, the mask are better for multiple bits eg trisa |= BIT_4_MASK | BIT_1_MASK;
  4. Can you post the driver code HERE, provide details on the wiring you have and give better details of what the problem is. We are half way down the second page and still have no concrete details on the problem.
  5. On the 16F913 port c is dual purpose with the LCD have a look at page 103 of the data sheet, though LCDEN is disabled on power up VLCDEN is enabled. Clearing this should release portc.
  6. Because you installed mikroC first and window (bless it) has decided that all file suffxed .c are to be used with mikroC.
  7. So the problem is compiling existing code with Sourceboost, why not post the code you have with details of the compile error then someone will be able to help you with the translation.
  8. C is case sensitive. portc and trisc have been defined in the header file for the processor you are using. PORTC and TRISC have not been defined.
  9. Dave, could I convince you that it was a second test? I seem to be all over the place this last week, must have be because of all those LEDs i did in the eighties!
  10. So what exactly have you been "trying for almost a week", and just how do you know non of it works?
  11. Set_bit and clear_bit are very efficient for manipulating single bits. In operations where the bit number is a constant they compile down to a single PIC bsf or bcf instruction. Masks are more efficient when the need is to manipulate a group of bits. #defining the mask to a meaningful symbol will make the code more readable. EG suppose we are using bits 0...4 of port b as a row of leds for a meter bar. using #define 0x1f METER_LED_MASK and using it latb &= ~METER_LED_MASK; // clear any set bits latb |= meterleds & METER_LED_MASK; // set l
  12. It is not wrong, it is a valid C operation, but because it can be a major cause of problems some compilers flag up a warning. It certainly should not generate an error.
  13. Actually, all of my formulae work just as well except the one for generating hundreds which I err.. a test, yes, that'll do! ... which was a test to see if any one was paying attention. I think you might find its actually: units=(number%10); tens=(number%100)/10; hundreds=number/100; Regards Dave <{POST_SNAPBACK}>
  14. Some compilers issue a warning when they come across this! Perhaps we could ask Dave about adding a warning.
  15. Does your C code have a function called void interrupt()? Could you post a minimal C program and the associated listing.
  16. The OP is refering to bit fields. Under your scenario typedef struct { unsigned char test[4] } testtype; then var.test[3]= 0; would be valid How can you assign to .3 ? var.test = 0; should work, but .3 is not defined as anything in your structure. If you had done: typedef struct { unsigned char test[4] } testtype; then i would think "var.test.3= 0;" would work fine as your then assigning to the third element ... or is that right.. bit rusty on my structure stuff. <{POST_SNAPBACK}>
  17. You can use C's MOD (%)and DIV(/) operators ones = number % 10; tens = (number / 10) % 10; hundreds = number % 100;
  18. As you are using hexa decimal and four bit masks Am I correct in assuming you mean split into ones, sixteens, and 256s? number = (number&0xf0) >> 4;.
  19. You dont need to set the banking, the compiler looks after that for you!
  20. I'll answer the first question but I dont have time to read through all the code. This pragma tells the compiler to insert data into the config memory of the pIC. Config memory is inaccessable at run time and is used to define how the PIC should set up its hardware. The settings you have are for _PWRTE_OFF Powerup timer off _BODEN_OFF Brown out detection off _WDT_OFF Watchdog timer off _LVP_ON Low voltage programming enabled _CPD_OFF Something to do with code protection(cant remember) _DEBUG_OFF Debug mode off _HS_OSC Oscillator set to hi
  21. But how do you output HelloWorld without a serial port or an LCD? Hey, stop giving away professional secrets!
  22. I guess it is some kind of BASIC with a thick accent due to spending a long time living in C country. zamhareers, is this program written in Proton PICBASIC?
  23. Some kind of Victorian work practise employing small children to push buttons because a gentleman would never perform such a working class task. Or have I misunderstood? Why a child? Regards Dave <{POST_SNAPBACK}>
  24. With PIC16 you cant. The stack is only seven deep and is totally inaccesable. The best you can do is to reduce the function call depth. NB using interrupts takes up one stack slot, calling functions in interrupts will take up more. Sourceboost has inbuilt (hidden) functions such as when you access an array in ROM or use the * / and % operators.
  25. I've long suspected Ted Trossin to be the fourth member of the Fabulous Furry Freak Brothers, this just proves it!
×
×
  • Create New...