MCLRE is just the name.
For internal (Not used for reset but the pins other functions) the fuse should be
_MCLRE_OFF
HS for the OSC
MCLRE is just the name.
For internal (Not used for reset but the pins other functions) the fuse should be
_MCLRE_OFF
HS for the OSC
Dave
Always wear safety glasses while programming.
Woo it worksIts a bit fast though. i put 100ms pauses in and it flashes a lot faster than when i use a 4MHz resonator. I know 16MHz is 4 times faster but i thought the point of declaring that was so "pause 100" would still take 100ms and not 25. Maby ive got something else wrong. I was reading about timers in the datasheet. I didnt understand any of it but part of it could mean the chip runs 4 times faster than the resonator you use.
It doesnt matter anyway. If i want 100ms then i just type 400. The point is the LED flashes. Tomoz ill get onto the real code but its 10:00 now so i should be getting to bed. Up at 4:30AM for work
Anyways. Thanx for that. I would have been lost trying to figure it out myself
Where are you setting the fuses? In the *.inc file or in the code.
A programmer never sleeps. When things get fuzzy is when some of the best work is done![]()
Last edited by mackrackit; - 28th November 2007 at 23:11.
Dave
Always wear safety glasses while programming.
Im setting the fuses in the programmer software right after loading the file. How do you do it in PBP? Its annoying having to keep setting them.
Also, Serial doesnt appear to be working. This is probs to do with the same problem but how do i figure out what value to give to spbrg? I found this page but im not sure what it all means. I entered 16 and it gives me a table. How do i know what BRGH is set to?
Edit: Just downloaded a calculator from Mister_e's website. It makes more sense but its still not working. I think ill go sleep on it![]()
Last edited by The Master; - 28th November 2007 at 23:25.
Solved the oscillator problem.
"DEFINE osc 16" doesnt work
"DEFINE OSC 16" does work
Serial still not working but i have a feeling thats something simple.
Ive tried 2 things from Mister-e's calculator
Code:DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive DEFINE HSER_TXSTA 20h ' Enable transmit, BRGH = 0 DEFINE HSER_SPBRG 25 ' 9600 Baud @ 16MHz, 0.16% DEFINE HSER_CLROERR 1 ' Clear overflow automaticallyI have also added this codeCode:RCSTA = $90 ' Enable serial port & continuous receive TXSTA = $20 ' Enable transmit, BRGH = 0 SPBRG = 25 ' 9600 Baud @ 16MHz, 0.16%
when any serial data comes in that should make the LED flash but its not doing. I think this might be to do with the circuit itself (currently thinking outside of the box. Using breadboard instead). Ill try and solve that tomoz. For now though i really am going to bed :P Ill let you know how it goes tomozCode:loop: if pir1.5=1 then newbyte=rcreg high portb.0 pause 100 low portb.0 endif goto loop
if you don't use any HSERIN/HSEROUT you use the second methode, unless you use the DEFINE method.
this one work here
just change DEFINE OSC, TXSTA and SPBRG to suite your requirement. Make sure you have a RS232 inverter (MAX232 or else) between your PC and your PIC.Code:@ __CONFIG _HS_OSC & _LVP_OFF DEFINE OSC 20 PORTB=0 TRISB = %00000010 RCSTA = $90 ' Enable serial port & continuous receive TXSTA = $24 ' Enable transmit, BRGH = 1 SPBRG = 129 ' 9600 Baud @ 20MHz, 0.16% PIE1.5 = 1 ' Enable USART interrupt start: if PIR1.5 = 1 THEN ' RCIF FULL? PORTB.0=1 PAUSE 200 PORTB.0=0 WHILE PIR1.5 TXREG=RCREG ' send it back to the pc ' utill USART buffer is empty wend if RCSTA.1=1 THEN ' ANY Overrun? RCSTA.4=0 ' YES clear it RCSTA.4=1 ' ENDIF endif goto start
And YES the DEFINE's have to be in capital letter, unless it will never work.
Last edited by mister_e; - 29th November 2007 at 15:24.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Thanx for the code. Just a few questions on it. "@ __CONFIG _HS_OSC & _LVP_OFF" causes an error.
Why do i need an "RS232 inverter"? Serial works fine through serin2. I think Matt did use one because theres some extra stuff on the serial input but i wasnt sure what it was for. It appears to be an optoisolator and a diode
Bookmarks