How is it working at all?DEFINE HSER_ODD 1
Get rid of that line...
How is it working at all?DEFINE HSER_ODD 1
Get rid of that line...
From mr_e's PIC MULTICALC . . .
Code:DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1 DEFINE HSER_SPBRG 92 ' 2400 Baud @ 3.579MHz, 0.21% DEFINE HSER_CLROERR 1 ' Clear overflow automatically
If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
.
Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
.
There simply is no "Happy Spam" If you do it you will disappear from this forum.
Okay. Below is my new code (I've added an LED to port b.6). Here's what happens. A capital 'A' shows on the terminal window, the LED goes on, the LED then goes out, another 'A' shows on the terminal, the LED goes on and there is where it stays. I never touched the keyboard during this time. After this process, it doesn't matter what I type in the terminal window, the light stays on and nothing else happens. Any thoughts?
Include "modedefs.bas"
DEFINE OSC 3
define HSER_RCSTA 90h
define HSER_TXSTA 24h
DEFINE HSER_SPBRG 92
DEFINE HSER_CLROERR 1
OSCCON= $08
'this is the layout for portb.5 - RB5/AN11/RX/DT
'turn off analog input for port b.5
ANSELH=0
'and any other analog stuff
ANSEL=0
'there's several analog comparators - lets shut them off
'I dont know which one - shut them all off
CM1CON0 =0
CM2CON0 =0
CM2CON1 =0
adcon1=0
'now set it for input
trisb.5 = 1
trisc.0 =1
rxPin VAR portB.5
txPin VAR portB.7
rxVal Var Byte
txVal Var Byte
loop:
pause 1000
'serout txPin,T2400,["A"]
hserout ["A"]
Pause 1000
High Portb.6
Pause 1000
'Low portb.6
hserin [rxVal]
'serin rxPin,T2400,rxVal
'pause 500
'serout txPin,T2400,[rxVal]
hserout [rxVal]
Low portb.6
pause 1000
goto loop
end
How about just a simple 'echo-ing' program to make sure everything is working first
Type on the PC, characters should show up on the PC. Led should blink once for each character received/sent-back. Don't type any faster than 54 characters per second.Code:Include "modedefs.bas" DEFINE OSC 3 DEFINE HSER_RCSTA 90h DEFINE HSER_TXSTA 24h DEFINE HSER_SPBRG 92 DEFINE HSER_CLROERR 1 Char VAR BYTE : led var portb.6 : output led : input portb.5 : output portb.7 Main: HSERIN [Char] : led = 1 : HSEROUT [Char] : pause 10 : led = 0 : GOTO Main END
Skimask,
Okay, I put in your program. The light blinks once (when I release from reset - I don't touch anything), no character is displayed and that's it. I tried putting a HSEROUT before your main loop and it does send out a character. Any thoughts about turning off the built in analog stuff?
Rob
My bad...yes, turn off all of the analog ports...everything over to digital.
Code:Include "modedefs.bas" DEFINE OSC 3 DEFINE HSER_RCSTA 90h DEFINE HSER_TXSTA 24h DEFINE HSER_SPBRG 92 DEFINE HSER_CLROERR 1 cm1con0 = 0 : cm2con0 = 0 : ansel = 0 : anselh = 0 Char VAR BYTE : led var portb.6 : output led : input portb.5 : output portb.7 led=1 : pause 500 : led=0 : pause 500 : led=1 : pause 500 : led=0 : pause 500 Main: HSERIN [Char] : led = 1 : HSEROUT [Char] : pause 10 : led = 0 : GOTO Main END
Last edited by skimask; - 28th October 2008 at 17:11.
Are you sure the PIC is running? Try a quick "blinky" without any serial stuff.
Dave
Always wear safety glasses while programming.
Mackrackit,
Yep, it's running. Follow the rest of my reply.
Skimask,
Sorry for the delay. I wanted to try some additional things. I'll explain in a bit. I tried the new code. It produces two long flashes on the LED and one very quick one. It then does nothing. No characters are displayed on the terminal and I can't enter anything. Thinking that it might be something else, I traded out the Max232 with a Max233 (eliminated the caps and such). Same results. I then tried a new 16F690 (thinking that the other one might have been damaged), same results. Anything we're missing here?
Rob
Bookmarks