Thanks Charles,
The board I am using has a Pic18F14K50. I will need to change the processor type, but is there anything else you think may trip me up?
aajgss
Thanks Charles,
The board I am using has a Pic18F14K50. I will need to change the processor type, but is there anything else you think may trip me up?
aajgss
I believe it should work as-is, as long as you change the processor type.
Charles Linquist
THanks Charles.
I was still having trouble, so went back to trying to write to serial EEprom. I was having no luck until I set
SSPCON =%00101011
Everything then started to happen. I thought that would be done in the I2CREAD and I2CWRITE.
Then by merging what you posted all looks good.
Thanks again for your help.
Now onto the next bit - trying to write values from the EEprom to the I2C DAC
This PIC stuff is great. I'm loving it!!
Well,
This project has developed a bit from the early start.
The initial bit was a learning curve on communications. The project itself was to create a 3 phase sinewave to drive a reactive power compensation board.
I changed from I2C to SPI and use 3 DACs to output the 3 phases shifted by 120 degrees.
Photos to follow. I used a free PCB software to produce the board. If anyone is looking for a free package, PCB Artist is really good.
Because I needed to have it switchable for 50 and 60 hz and to get the timing correct, I used a PAUSEUS command to get my delays. Is there any issues with that command? It seemed to work ok up to a couple of hundred uSecs, but after that the PIC would not run. I ended up putting in a for next loop and adjusting the number of times the loop executed to get the correct timing.
Sorry cant post the code at the moment as its on my work computer.
Thanks
aajgss
There is nothing wroing with the PAUSEUS command, but if you using a variable after the PAUSEUS, it should be a WORD variable.
Without looking at your code, there is no way of knowing what effect the longer delays may have.
Anything that requires close timing should be done with a timer. Even if you aren't using interrupts, you can use a timer by setting up the prescaler and clock source, and turning the timer ON. When you want to start your timing interval, you clear the timer, and later on in the program you can sit in a loop until the timer is > a certain value. The upside is that you can do other tasks after you start the timer, and as long as the tasks don't take longer than your desired time interval, timing will be maintained. And this technique works especially well if you DO use interrupts, because the interrupts can "steal" time from the main loop, and make the PAUSEs take longer than their set value. Using a timer keeps timing perfect.
The downside is that at 40MHz, TMR1 times out in ~52mSec even with a /8 prescaler.
Charles Linquist
I guess I should have also added that TMR0 can have a lot longer time period because it has a /256 prescaler. I just always use TMR0 for my main interrupt timer and TMR1 for the time delays in the loop. You could reverse the operation and use TMR1 for ints and TMR0 for the loop timer. That will get you over 1 second.
Charles Linquist
Bookmarks