Jump to content


Photo

Serial Port


1 reply to this topic

#1 tom 2007

tom 2007

    Regular

  • EstablishedMember
  • Pip
  • 58 posts
  • Gender:Male

Posted 20 October 2007 - 02:54 PM

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 | &#40;1 << PEIE&#41; &#39;enable peh. interrupts
	intcon = intcon | &#40;1 << GIE&#41; &#39;enable global interrupt
	pie1 = pie1 | &#40; 1 << RCIE&#41;
	trisb.1 = 1 &#39;enable for input
	trisb.2 = 1 &#39; &#34;	   &#34;  &#34;
	spbrg = 207 &#39;@ 16Mhz&#58; 1200 baud
	txsta = txsta & ~ &#40;1 << BRGH&#41;
	txsta = txsta & ~ &#40;1 << SYNC&#41;
	rcsta = rcsta | &#40; 1 << RX9&#41;
	rcsta = rcsta & ~ &#40;1 << ADEN&#41;
	txsta = txsta | &#40;1 << CREN&#41;
	rcsta = rcsta | &#40; 1 << SPEN&#41;
	cmcon = 7
				&#39;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

#2 c58_4311

c58_4311

    Regular

  • EstablishedMember
  • Pip
  • 62 posts

Posted 22 October 2007 - 10:23 PM

dear TOM,


Please see if you can recieve and send the characters via USART without using interrupt. You can follow he example code written in boostbasic.



Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users