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.

Reading and storing serial port data

Status
Not open for further replies.

hithesh123

Full Member level 6
Full Member level 6
Joined
Nov 21, 2009
Messages
324
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,298
Location
lax
Visit site
Activity points
3,548
Reading and storing serial data

How do I read serial data and append it to a byte.
I am reading a bit from one data line on falling edge of a clock, I need to append it to a byte.
MCU is C8051F120. compiler is keil C51

Can I do (inside a for loop)

mydata=((mydata<<1)|port_bit);
 

Re: Reading and storing serial data


Sorry, I checked this link https://saeedsolutions.blogspot.in/
Saw a UART code example (not software UART).

Anyway the I2C code is kinda convenient. The clock is generated and data read in the same routing. You control both clk and data. But I am reading data on falling edge of clock (Interrupt based).
I am able read the data now. But still not efficient.

I have to read 11 bits. The first bit is start bit, the next 8 bits are data and then parity bit and stop bit.
Do I read and store everything in integer data type or store them separately in the ISR. I am storing them separately now, the ISR takes a long time to execute.
 
Last edited:

It's not exactly UART. It's software I2C.
Still vague. You mean I2C slave?

Provided you are trying to make a software I2C slave, it's considerably different from a software UART, I don't think that software UART examples are of much help.

Essentially, an I2C slave has to observe SDA and SCL changes. SDA must be monitored at least for start and stop condition, SCL to clock the serial data.
 

Still vague. You mean I2C slave?

Provided you are trying to make a software I2C slave, it's considerably different from a software UART, I don't think that software UART examples are of much help.

Essentially, an I2C slave has to observe SDA and SCL changes. SDA must be monitored at least for start and stop condition, SCL to clock the serial data.

FvM,
I am just trying to read and store data on falling edge of the clock.
ultimately, I want to implement this for PS2 keyboard protocol. Debugging is easier with I2C. So I am doing with I2C first.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top