Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
April 19, 2024, 01:49:05 01:49


Login with username, password and session length


Pages: [1]
Print
Author Topic: Help on schematic...  (Read 4469 times)
0 Members and 1 Guest are viewing this topic.
MicroBox
Junior Member
**
Offline Offline

Posts: 35

Thank You
-Given: 11
-Receive: 0


« on: May 01, 2009, 11:27:38 11:27 »

Hello everyone,
                   I'm a beginner on PBp/electronics and trying to make a sample code run on my hardware. The code is from   
picbasic.co.uk/forum by mister_e. The program blinks the green LED on PortB.0 and should trigger(On/Off) red LED on PortB.1 upon entering 1 or 2 on the hyperterminal. I got the code running on proteus, but on the hardware side I hadnt had much luck, I hope anyone can help me here...any help is appreciated.
Kindly check my connection diagram..
Code:
DEFINE OSC 20               ' running at 20 MHZ
   
    '    PORT setting
    '    ============
         '
         TRISC=%10000000        ' RC.7 => USART RX pin set to input
                                ' all other pin set to output
                                '
         TRISB=0                ' RB<7:0> set to output
   
    '    USART setting
    '    =============
         ' Since we will not use HSERIN/HSEROUT, we must
         ' write directly to internal PIC register
         '
         TXSTA=$24              ' enable transmit and SPBRGH=1
         RCSTA=$90              ' Enable USART and continuous receive
         SPBRG=129              ' BAUD RATE = 9600 BAUDS
   
    '    Interrupt definition
    '    ====================
         '
         PIE1.5   =1            ' enable USART receive interrupt
         INTCON.6 =1            ' enable peripheral interrupt
   
    '    Alias definition
    '    ================
         '
         RCIF      var PIR1.5   ' receiver interrupt
         StatusLED var PORTB.0  ' the LED who show a 'running process'
         UserLED   var PORTB.1  ' the LED that user want to control
         
    '    Variable definition
    '    ===================
         '
         Delay     var word     '
         DataIn    var byte     ' use to store RCREG content
         Discard   var byte     ' use to erase RCREG register
       
    '    Hardware/software initialisation
    '    ================================
         '
         PORTB=0                ' clear PORTB
         
         on interrupt goto USARTInterrupt
     
Start:
    '    Main program loop that make the user happy to
    '    see a LED flashing to mean that something is
    '    running
    '
     
    toggle statusled
    for delay = 1 to 5000       ' use a loop delay to ensure
      pauseus 5                 ' getting interrupt as fast as
      next                      ' possible
    goto start
   

disable interrupt
USARTInterrupt:
    '    Here's the interrupt routine who will make the user
    '    much happy by giving him the feeling to have the
    '    control on the machine when the status of the user
    '    LED will change
    '
    RCSTA=0                     ' Disable serial port AND
                                ' clear possible error (FERR,OERR)
                               
    datain=RCREG                ' Get data
                               
    while RCif                  ' wait untill the RCREG is empty
          discard=RCREG         ' by reading it and store result in a
    wend                        ' don't care variable
                               
    select case datain          ' What to do with that data???
                               
           case "1"             ' User selection = 1
                userled=1       '      => Enable the LED
                               
           case "2"             ' User selection =2
                userled=0       '      => disable the LED
               
     end select           
    RCSTA=$90                   ' Re-enable the serial PORT AND
    resume                      ' get out of here
enable interrupt


________________
thanks
« Last Edit: May 01, 2009, 11:35:19 11:35 by MicroBox » Logged
jeanninemtv
Senior Member
****
Offline Offline

Posts: 311

Thank You
-Given: 57
-Receive: 25


« Reply #1 on: May 01, 2009, 12:10:55 12:10 »

hey
you forget to connect a serial transceiver like max232 before attach to pc serial port if not you are killing your serial pins from mcu....

hurry up
Logged
pickit2
Moderator
Hero Member
*****
Offline Offline

Posts: 4647

Thank You
-Given: 826
-Receive: 4207


There is no evidence that I muted SoNsIvRi


« Reply #2 on: May 01, 2009, 02:31:49 14:31 »

hey
you forget to connect a serial transceiver like max232 before attach to pc serial port if not you are killing your serial pins from mcu....

hurry up
You don't need to use Max232 with a lot of pic chips, I'm have working a pic12F675 as a door open monitor, I have GPIO.0 and GND straight to the serial port pins via 1K resistor 2. and 5.

also see PDS Manual page 360.
« Last Edit: May 01, 2009, 02:37:07 14:37 by pickit2 » Logged

Note: I stoped Muteing bad members OK I now put thier account in sleep mode
chandra2sekhar2000
Active Member
***
Offline Offline

Posts: 127

Thank You
-Given: 24
-Receive: 18


« Reply #3 on: May 01, 2009, 03:12:39 15:12 »

hello
use a max 232.it inverts the bits received.so.it will work fine.or if u want u can use a transister switch .i.e connect the tx out to base .use a pull up .then con connect from collecter to micro.it will work .try this first in proteous itself.

in order to debug .resend the receved data to pc connecting the output from max232 to pc rx pin,2,.
Logged
twonuts
Active Member
***
Offline Offline

Posts: 118

Thank You
-Given: 55
-Receive: 42


« Reply #4 on: May 06, 2009, 02:30:33 14:30 »

You can also simulate your circuit in Proteus/Isis, and use Hyperterminal or some other terminal program to monitor pic serial output.

Use the COMPIM component in your circuit as serial port connection.
Get virtual serial port program which sets up two virtual serial ports back to back in your PC.

Direct COMPIM to one of these virtual ports, and use hyperterminal connected to the other virtual serial port of the connected pair to monitor serial data from the pic.

Doing this way you see actual data that your PC would  receive as well as seeing what you intend the PC to receive using just a virtual terminal in ISIS.


« Last Edit: May 06, 2009, 02:39:23 14:39 by twonuts » Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright © 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC