Jump to content

Recommended Posts

hello

 

I want to receive data from my pc to the PIC. I have configured everything (not sure if it is correct) but there is no interrupt generated.

 

code:

 

#pragma DATA 0x2007,0x3D0A 'HS OSC
#pragma CLOCK_FREQ 16000000

sub interrupt ()
dim Data as byte
porta.3 = !porta.3 'to test if interrupt gen. but doesn't do anything
if pir1.5 = 1 then
	Data = rcreg
	'process Data ...
	pir1.5 = 0
end if
end sub

sub main()
trisa.1 = 0
trisa.2 = 0	
trisa.0 = 0
intcon = intcon | (1 << PEIE) 'enable peh. interrupts
intcon = intcon | (1 << GIE) 'enable global interrupt
pie1 = pie1 | ( 1 << RCIE)
trisb.1 = 1 'enable for input
trisb.2 = 1 ' "	   "  "
spbrg = 207 '@ 16Mhz: 1200 baud
txsta = txsta & ~ (1 << BRGH)
txsta = txsta & ~ (1 << SYNC)
rcsta = rcsta | ( 1 << RX9)
rcsta = rcsta & ~ (1 << ADEN)
txsta = txsta | (1 << CREN)
rcsta = rcsta | ( 1 << SPEN)
cmcon = 7
			'program starts here....
end sub

 

Anyone knows if this code is correct? Also the signal at RX pin is this inverted from the PC signal or is it the same?

 

Configuration at pc: 1200 baud, no parity, 8 bits, 1 stop bit

 

Thnx

Tom

Share this post


Link to post
Share on other sites

Your content will need to be approved by a moderator

Guest
You are commenting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoticons maximum are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×