Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

USART on Pic18f1320, no activity on TX pin

Status
Not open for further replies.

Chamrog

Newbie level 2
Newbie level 2
Joined
May 19, 2013
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,306
Greetings,

I'm using trying to set up communication using USART on the PIC1320, but it does not want to play nice :) I do suspect that this is a configuration problem. I planned on being able to both send and receive, but so far nothing shows up, from the micro-controller. Im using proteus as simulator, and MikroC as the compiler.

What i see.

1. nothing is output from the micro controller, i can however see that the usart does what i want

2. using the virtual oscilloscope i can see that the the things i type in the terminal are send "on the line"
3. i have set up RB0 to flash, and i can see that it does that as expected.
4. The RX line is high, but the TX line is constantly low, should it not be high when nothing is being send?


Part of the microcontroller config



Is there someone here that can tell me what silly mistake i have made? :)

/C

Mikroc Code, mostly just the example from MikroC with the on/off added as a sanity check.

Code:
char i, error, byte_read;
           char uart_rd;

void main(){

  OSCCON = 0b01000000       ;     // set 1 MHZ
  ADCON0.B0 = 0;                // analog converter disabled
  ADCON1  = 0b11111111;                             // Configure AN pins as digital I/O
   TRISB.B0 = 0;
   UART1_Init(9600);               // Initialize UART module at 9600 bps
  Delay_ms(1000);                  // Wait for UART module to stabilize
  UART1_Write_Text("Start");
  UART1_Write(10);
  UART1_Write(13);

  while(1){
    LATB.B0= ~LATB.B0;
    delay_ms(100);
    UART1_Write_Text("k");
  UART1_Write(10);
  UART1_Write(13);
   }
  }

 

Hi;
Some notes:

1.
Seems the PIC TX pin (RB1) is grayed out, so examine your ADCON1 setting because it's wrong. ADCON1 = 0x70 needed (not 0xFF) to set RB0, RB1 and RB4 as digital I/O pins. See the datasheet.

2.
The MAX232 inverts the signals so connect the Virtual Terminal before, directly to the PIC RB1-RB4 pins.

3.
Examine the PIC clock value in the Proteus: it must be the same (1 Mhz) as in the mikroC project.

Attach here the entire mikroC project (with the DSN, in a rar or zip) then may be we can give more help.
 

Hi Zuisti,

Thank you for taking time to replay, to my clearly newbieish questions :)

1. i changed the settings to match the 0x70, but i dont see this as being the issue, all the pins were set for digital(0xFF), with bit 7 always read as zero, but anyway im no expert, so i do as im told :)

2. i attached the terminal directly to the pins, but there is no signal change on the pins, which i checked earlier with the osciliscope, i could see the characters that i typed in the terminal on the osciliscope, but the TX pin remained idle.
3. As far i can see from the osccon register the clock par 0b0100 should equal 1Mhz.

And i have noticed from the debug log for the MCU in Proteus, that the controller does infact recieve data when i type something in the terminal, when its hooked up through the max232, so there is must be something wrong with the way i have set up transmit data


update: I have build up the MCU part on a breadboard, and here i can clearly see the micro transmitting, so there must be something up with the setup i have in proteus
/c
 

Attachments

  • usb control1.zip
    121.9 KB · Views: 53
Last edited:

Hi;
For an hour I tried, but without any success, the USART does not initialized. Seems the 18f1320 Proteus model (or the datasheet :wink:) is wrong, because the 18f2620 is working like a charm. Try it, with the following settings:
Code:
     INTCON = 0;
     CMCON  = 0;
     ADCON1 = 15;


A note: at 1 MHz clock the max. baudrate is 2400, use 1200 Bd instead of the 9600 (too large error, the compiler signalizes it).

Are you using a Proteus 8? I've a ver 7.10 only :sad:
 

Attachments

  • working_1320.jpg
    working_1320.jpg
    17.4 KB · Views: 81
  • usb control.rar
    33 KB · Views: 60

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top