what is the possible mistake that I had made??
why did the PIC reacted that way, I had checked the connections everything is connected on where they should be connected...and also Im transmitting data through serial port "wirelessly".
the serial port is working properly, I've transmitted some commands and the pic responded to it, but later the pic stopped working...I really dont know what happened..., I use EEPROM on pic, to store about 30commands then execute those commands after receiving the last command(the 30th),...do i need to include a command to erase the EEPROM to be able to receive a new 30command batch, is there a command for erasing EEPROM?With some PICs the program can be changed by the PIC itself but it is an advanced topic so I don't think you progammed that.
What do you mean you transmit data wirelessly?
Maybe the serial port is not working anymore.
Im using 16f628A this is my code:After reset the program does work again, or everything is dead after your first trail? Did you try to reprogram the chip?
You didn't mention which pic type you are using.
Remember that posting your code and the wiring diagram of the project is the best way to have the problem solved quickly.
Alberto
Question: are using picbasicPro?
There are some issue with your code:
1) You are using the internal oscillator without setting the register for the required frequency.
2) you are using portA.0 for serial input and you have commented out the trisA command. It should be TRISA = %00000001
3) I don't see the reason to write the eeprom and then read it back. Use an array of bytes for this purpose.
Remember that eeprom has a 100K write cycle than they don't work anymore, so it is not reccomandable to write to them in loops.
If necessary to hold the data this should be done at the end (before switch off )
4) If you use picbasic then you have to INCLUDE "Modedefs.bas" for the correct serial setting (true 9600 bauds)
5) Don't see the reason for the while/wend loop.
6) Your schematic doesn't show any wiring
If you need I will arrange your code, if you tell me what you want to achieve and complete the wiring diagram.
Alberto
I read the datasheet for 16F628 and actually you were correct, this chip has only one fixed frequency for the internal oscillator (4 MHz). So there is no OSCON register to set.
The code below should work, I did compile it without your @Device setting because my compiler works differently. Tray it and see.
Alberto
Rich (BB code):@ DEVICE pic16F628A,INTOSC_OSC_NOCLKOUT @ DEVICE pic16F628A,WDT_OFF @ DEVICE pic16F628A,CPD_OFF @ DEVICE PIC16F628A,PROTECT_OFF @ DEVICE PIC16F628A,BOD_OFF @ DEVICE PIC16F628A,LVP_OFF @ DEVICE PIC16F628A,MCLR_OFF INCLUDE "Modedefs.bas" CMCON=7 DEFINE OSC 4 PortB = 0 PortA = 0 TRISB = %00000000 TRISA= %10000011 False con 0 True con 1 B0 VAR BYTE CNT VAR BYTE i var byte marcus var byte q var byte MAIN: i = 0 Q = 0 WHILE i < 6 SERIN PORTA.0,2,["A"],B0 WRITE 1*i,B0 i = i + 1 wend LOOP1: while q < 6 read 1*q,marcus Q = Q + 1 IF marcus.0 = true THEN HIGH PORTB.3 else low PORTB.3 ENDIF IF marcus.1 = True THEN HIGH PORTB.4 else low PortB.4 ENDIF IF marcus.2 = True THEN HIGH PORTB.5 else Low PortB.5 ENDIF IF marcus.3 = true THEN HIGH PORTB.6 else low PortB.6 ENDIF PAUSE 1000 GOTO LOOP1 WEND GOTO MAIN end
I use max232, before the transceiver the PIC's circuitry is place with the other transceiver. I checked the datasheet of both the transceivers, the max232 all seem to be connected correct, also with the PC's serial port. My only problem is I can't perform SEROUT, but I can perform serin. I really don't know where would the SEROUT 'output' would be displayed,Will it be displayed on the same hyperterminal I've been transmitting with.You need to open only one hyperterminal (two will conflict if using the same serial port).
How did you connect the pic to the PC? Via a level translator (max232) or directly with a resistor.
Can you show both the connection for Tx and Rx between the pic and PC?
The reason is that the level translator will invert the signal, so you will use the "TRUE STATE" mode 2, otherwise you shoul use the "INVERTED STATE" mode 6 for both Tx and Rx.
Alberto
The datasheet said to remove jumper from JP3, but when I remove it I could not transmit any signal but If I put it back again it does transmit, does that mean that my assembled rs232 level translator is faultyThe document you have attached is for an assembled board, I was talking about the 16 pins chip max232!
I cann't say much about this assembled rs232 level translator appart that you have to remove the jumper from JP3 and that you have to make sure that all the wiring are correct as per the datasheet you have posted.
If after deep check you come to the conclusion that wiring are all correct and reliable then the only answer is that Tx line is faulty and you have to change the board. (I wish not)
In such an unluky event take into consideration to buy the maxim max232. (will cost you few cents)
Alberto
| Thread starter | Similar threads | Forum | Replies | Date |
|---|---|---|---|---|
|
|
Nasm compiling binary | Software & IDEs | 1 | |
| Y | Nodemcu esp8266 Ubuntu VM compiling basic example problem | Microcontrollers | 0 | |
| F | Problem compiling a C program | Programming & Languages | 3 | |
| D | compiling problem with MPLAB | Microcontrollers | 5 | |
| M | Assembly language Compiling problem...pls help | Microcontrollers | 6 |