Jump to content

ra68gi

EstablishedMember
  • Content Count

    229
  • Joined

  • Last visited

Everything posted by ra68gi

  1. Read data sheet on how to set Porta analog pins to digital mode. If your chip is 16F series &has got adc multiplexed with porta pin include adcon1 = 7; if it has analog comparators then write comcon = 7 ; Regards Raghunathan.
  2. Yes, it should work. I have not tried it. The data sheet says that the data EEPROM and Flash program memory is readable & writable during normal operation. The EEPROM data memory allows single-byte read and write. The flash program memory allows single-word reads and four-word block writes. program memory write operations automatically performs an erase-before write on blocks of four words. A byte write in data EEPROM memory automatically erases the location & writes the new data(erase-before-write). One other aspect while designing would be the erase/ write cycles of your memory
  3. Rom objects can't be modified using C. The only option to do this is to use inline assembly (on targets that support run time flash write). Regards, Pavel Hi DavidT, Are you talking about the eeprom or the program flash memory? You can store & retrive your array using eeprom_read & eeprom_write function any where in your program. At this point i am a bit confused with what Pavel has mentioned. Does the flash_read , flash_loadbuffer, flash_write not work with data flash memory chips when invoked in a c program? I think i need to know what is what. eeprom?, program mem
  4. Hi emte, I think the cost of C30 compiler from MicroChip for PIC24 & dspic is around $750. Regards Raghunathan.
  5. Hi Dave & Pavel, Is there any plans of coming out with a compiler for the 16 bit / dsp PIC micros? Regards Raghunathan
  6. Give a couple of days time & i will post a example program with circuit schematics in my thread. Regards Raghunathan
  7. Hi guys, I am using the hwusart of PIC16877 to send two data to a PC. The the two datas are the load value(from load cell) from an external adc chip and a positional value reading from a quadrature encoder. Lets say the variables are int load_value = 198 ; & int encoder_value = -65 ; I will be sending the characters in the following format.. #00198,-00065 I am using the sprintf function to convert the var to string & then display.For the radix i use "%05u". But when i receive it on the terminal screen, this is what i get.. #00198.,-00065. I am getting th
  8. Hi Laurence, For a quick start try this thread.."PIC micro programming in BoostC for beginners" As far as printf command is concerned you have lprintf used only with LCD. See page 78 of BoostC manual. for serial communication you can use serial_printf command available in the folder named lika.be( i don't know if it comes with the source boost ide down load or whether i down loaded it from his website)lika.be Regards Raghunathan.
  9. I think you can enable the watch dog timer. The #define MODE (USART_reset_wdt | USART_HW) will automatically clear your wdt before it resets. I think you might be facing some other problem & not related to wdt. See if your Rx buffers are overflowing and so receive disabled.
  10. Hi DavidT, It may be difficult to work with interrupts in your case ( due to key bouncing). Why don't you try some thing like this.. Lets say you have connected the switch to portb.0 & based on the duration you have pressed you decide what activity to do. if(portb.0==0) { delay_ms(100); // wait for the key to settle down. if(portb.0==0) { for(x=1;x<1000;x++) { y=x; delay_ms(1); if(portb.0==1) { break; } } if(y<=500) { write to eeprom; } if((y>500)&&(y<750)) { light 12 leds; } if((y>750)&&(y<999)) { do some thin
  11. Hi guys, In my project I am using 3 interrupt sources, they are tmr0, RB0/INT, ccp( capture interrupt) all as external interrupt on pulse. I have a problem with the ccp interrupt. The problem is every time there is some noise ( electrical disturbance from power line etc) the ccp interrupt gets disabled. I need to reset the system to get it to work again. I found that such noise ( as found in my present circuit setup) does not have any effect on the tmr0 or RB0/int interrupts. Right now i can do away with this problem by simply changing the interrupt source to tmr1 but my future projects ma
  12. You didn't mention if you used a debugger. When you use the ICD2 you must always include the icd2.h header: #include <system.h> #include <icd2.h> The compiler then protects the file registers used by the icd2 firmware. This might explain your unexpected changes in values. /Mark No, i haven't used a debugger, just direct load onto target board & check. I solved the problem by just declaring all the arrays with 6 elements. There is one small error in my ISR code. I initially had just 2 interrupt sources & hence used if else command. Latter i added one
  13. Hi ryeg, First try it on portb, see if it works then use porta. What chip are you using ? chips such as PIC12C67x, PIC16C7xx, PIC16F87x porta pins will come up as analog pins. to use as digital write adcon1 = 7; Some chips like 16C620, 621, 16F627,628, have analog comparators on porta & you need to disable them to use them as digital pins, so use comcon = 7; Regards Raghunathan.
  14. Hi guys, I have already said this in my previous thread, yet.. I am currently working on a project in which the pic is made to read adc values from an external adc chip. The adc chip outs the data in a bcd format (-20,000 to +20,000 counts) & it generates 5 strobe pulses during which it outs the 5 digits of its adc result. Using ext interrupts i load these value into the pic. Simultaneously I am reading a rotary positional encoders output again thro' ccp interrupts . The value of the adc or the encoder is displayed on to 6 no. of 7-segment led display which are multiplexed on to 8 i/o p
  15. No priority interrupts, I am using pic16f877. I am talking about software usart and so it does not generate any interrupt ( for that matter i think even the hw uart lib of source boost does not generate interrupt, but does a software polling of the interrupt or status flags( the rx & tx interrupt enable bits are cleared). I don't want to use my own routine. If i use the SB lib i have the advantage of handling strings ,ascii etc with ease( i suppose, i haven't tried). Regards Raghunathan.
  16. I am currently working on a project in which the pic is made to read adc values from an external adc chip. The adc chip outs the data in a bcd format (-20,000 to +20,000 counts) & it generates 5 strobe pulses during which it outs the 5 digits of its adc result. Using ext interrupts i load these value into the pic. Simultaneously I am reading a rotary positional encoders output again thro' ccp interrupts . The value of the adc or the encoder is displayed on to 6 no. of 7-segment led display which are multiplexed on to 8 i/o pins. Now i also need to transmit the adc and encoder values thro'
  17. I don't see an issue here, msb indicates the sign when a negative number is stored as 2's complement. Don't known quite what you are talking about. Regards Dave Hi Dave, I am using an encoder & the result is stored in a variable which can take any value positive or negative,which i don't know. If i knew that my result is negative then what you say is right, the last bit becomes the sign bit. I just wanted to know if there was a easier way of knowing if my variable was positive or negative just by reading some bits. Regards Raghunathan
  18. emte, this sign conversion is confusing. The signed values are stored in two's compliments.Say we have a signed char x;, both -1 and 255 will be stored in a similar way & only the compiler seem to know if its -1 or 255, because when i use the simulator to display portb = -1 ; it displays all lit leds or value 255. or if i try to read it, the value turns out to be 255. The only way i can check is to write if(x<0).I have not tried what you have mentioned above, but could you explain. If there is a way to avoid duplicating the display code i would be happy. note: The signed character x
  19. Hi guys, I want to display a signed variable on a seven segment display. Right now i am checking if its a negative value if so converting it into positive value by multiplying it with -1 and then displaying it. Is this the only way to do it ? Part of the code... while (1) { if (portd.6 == 0) { encoder_display_flag = 1; if (encoder_update_flag == 1) { encoder_update_flag = 0; if( counter < 0 ) { counter1 = (-1)*counter; // signed long counter; & unsigned long counter1; encoder_sign_flag = 0; digit[4] = counter1 / 10000; digit[3] = (counter1
  20. Hi, How is the sign bit in a variable stored ? Can i access the sign bit directly in boostC like i address the individual bits through dot operator? Raghunathan.
  21. You could also declared a union to do the job. typedef union { unsigned int val; struct { char hi; char lo; }byte; } HL; void main() { HL hl; hl.val = 0x1234; char hi = hl.byte.hi; char lo = hl.byte.lo; while( 1 ) } Regards Dave <{POST_SNAPBACK}> I checked the code on the simulator and found that the lo byte value & hi byte value are interchanged. I suppose the struct should be declared as... typedef union { unsigned int val; struct { char lo; // first the lower byte char h
  22. Hi emte, Its just today that i started to read the data sheet of 16f8xx on the USART module. I realize that the flag rcif can't be cleared in software. Its cleared only in hardware & this happens when you read the rcreg register. I think upon reading the rcreg, it automatically gets cleared (gets empty). And since rcreg is a double buffered, capable of storing 2 bytes of data it may probably take 2 reads before you can clear the rcreg register and rcif flag. The only way to disable the interrupt is to clear the rcie enable bit. Am i write ? can you add some more information to improve my
  23. Hi Guys, I know i should ask the microchip guys this doubt, & i did register it. I thougtht i would get a quicker response from here. I have a chip marked 16F877A-I/P. From page DS39582B-page231 of your data sheet the chip's operational frequency is written as 10Mhz. So, does that mean i can't use a 20MHZ crystal. IF so what should the chip be marked to operate at 20mhz. Any idea? Regards Raghunathan
  24. You could also declared a union to do the job. typedef union { unsigned int val; struct { char hi; char lo; }byte; } HL; void main() { HL hl; hl.val = 0x1234; char hi = hl.byte.hi; char lo = hl.byte.lo; while( 1 ) } Regards Dave <{POST_SNAPBACK}> For those who are new to C programming this bit of information may be useful. Dave, please tell if i am wrong. The above is a very good example of using union & struct not available in BoostC user manual. the syntax for using the struct is as follows..
×
×
  • Create New...