Soft-Uart Tx only using software delays only

I was working on a code for a module on my GSM gateway today , for which I had given 1 pin of micro-controller to use as software Tx. Software UARTs usually uses timers to make them robust, but I had already used them all. So I decided to write a code using software delays.

The UART logic is inverted , so to send logic 1 you have to send low signal  and vice versa . Here is my code , hope it might help someone else.

/*
* soft-uart Tx only without any timmer uses software delays
* the baud rate depends on the delay in us , here I am using
* 4800 with a 1 start bit, 8 databits and 1 stop bit
* if you wanna change the baud rate calculate it by 1/baud and
* modify the _delay_us();
*
* Created: 11/21/2012 1:52:37 PM
* Author: AbuUmar
*/
#include <avr/io.h>
#include <util/delay.h>
#define portlow PORTC&=~0x01
#define porthigh PORTC|=0x01
void putchar_soft(char data_soft)
{
 char bit_count=10; // 1+8+1SB
 data_soft=~data_soft;
 char secc=1;char0:
 if (secc=1)
 portlow;
 else
 porthigh;
 _delay_us(208);
 //_delay_us(208);
 for ( char i = 0; i < 8; i++ ) {
 if(data_soft & 1)
 portlow;
 else
 porthigh;
 data_soft=data_soft>>1;
 _delay_us(208);
 }
 porthigh;
 _delay_us(208);
 _delay_us(208);
 return;
}
int main(void)
{
 DDRC|=0b00000001;
 porthigh;
char inte=0;
while(1)
 {
 // example use, initializing a var to 0 and sending the data
 // with 1 sec delays
 putchar_soft(inte) ;
 _delay_ms(250);
 _delay_ms(250);
 _delay_ms(250);
 _delay_ms(250);
 inte++;
 }
}
 

Beagle Bone linux images

What is BeagleBone Black?

BeagleBone Black is a low-cost, community-supported development platform for developers and hobbyists. Boot Linux in under 10 seconds and get started on development in less than 5 minutes with just a single USB cable.

MKCCE3-0_grandeMKCCE3-1_grande

Processor: AM335x 1GHz ARM® Cortex-A8

  • 512MB DDR3 RAM
  • 4GB 8-bit eMMC on-board flash storage
  • 3D graphics accelerator
  • NEON floating-point accelerator
  • 2x PRU 32-bit microcontrollers

Connectivity

  • USB client for power & communications
  • USB host
  • Ethernet
  • HDMI
  • 2x 46 pin headers

Software Compatibility

  • Debian
  • Android
  • Ubuntu
  • Cloud9 IDE on Node.js w/ BoneScript library
  • plus much more

 

 

 

 

 

The following link hosts all beagle-bone images and is actively maintained.It includes flasher and SD card images of angstrom, debian and ubuntu builds. Those who wish to compile the kernel from source may also do so.

https://rcn-ee.net/deb/

 

STM32 Microcontrollers – Prior to Start

STM32 ARM-based micros from STMicroelectronics pack high density resources than any other conventional microcontroller. They are also high speed devices, operating typically at 72MHz and beyond. Despite several advanced features and heavy resources, they turn out to be misfortunes for beginners who wish to play with them. Available in market are several cool STM32 boards but most of them are not well documented. The aim of this document is to address some common FAQs.

Typically most people ask the following question:

  • How to program the STM32 micro embedded in my development board?
  • What tools do I need to get started?
  • What compiler support do I have for STM32?
  • What resources are available for STM32 on the internet?

… 

 

yet another seven segment display code generator/calculator

Yesterday I made a post regarding a seven segment display code generator, One of our reader Zafer shared his work with us through the comments section. Its a nice and useful utility. Its in Turkish language but its easy to use. Download it here  from Dropbox.

Hi Muhammad
I follow your site with interest.
I’ve prepared the following program. hopefully be useful.
Zafer
http://yadi.sk/d/0PqFkSf2P9gJr

 

 

Seven segment Display code generator / calculator

I found this awesome code generator for seven segments. There are many out there but this one has some good features. first of all you can decide which Segment is attached to which pin  [all pins should be on one port].  secondly you can get values for multiple characters and the code generator will make an array of values for you .

Give it a try. It can be downloaded here  or from codeplex website.

Capture

 

“COM Port Physical Interface Model” COMPIM from PROTEUS

I found an interesting feature from Proteus, so-called COMPIM serial port model. The Virtual System Modeling capabilities of Proteus VSM allow the creation of models that can actually interact with the physical world. Such models are called Physical Interface Models or PIMs for short.

The COMPIM model is a Physical Interface Model of a serial port. Incoming serial data is buffered and presented to the circuit as a digital signal, whilst serial digital data generated by a CPU or UART model appears at the PC’s physical COM port. The physical COM part also includes virtual COM port over USB and Bluetooth with some work-around. The COMPIM model also provides for baud rate translation, and for optional hardware or software handshaking on both the physical and virtual sides of the device.

This allows any real world hardware equipped with a serial port to interact with a Proteus VSM simulation. For example, you could use it to develop a program for a microprocessor within Proteus VSM that would operate a real physical modem, perhaps as part of a security or home automation system. By default, the COMPIM supports 4 physical ports.

 

writing and reading from AVR EEPROM in Block.

EEPROM can be used to store non volatile data of the program , sometimes you need to write arrays even multidimensional. The way I do it is by using EEMEM attribute. EMMEM is used to allocate space in EEPROM.

I use the Macros given below to write or read to EEPROM. you have to use #include I would be precise . below is the Code.

#include

//////////////////////////////////////////////////////////////////////////
//        Macros and # Defines
//write block to EEPROM
#define eepw(message,EEADDR,BLKSIZE) eeprom_write_block((const void*)message,(void*)EEADDR,BLKSIZE);
//read block from EEPROM
#define eepr(readblck,EEADDR,BLKSIZE) eeprom_read_block((void*)readblck,(const void*)EEADDR,BLKSIZE);

uint8_t EEMEM eepstring[15];

Example use

eepw("sample test 1",eestring, 15);  // "writes sample test1" to eestring in EEprom ,
char d[15];   //array in ram
eeprom_read(d, eestring[0],15); // reads the data and puts it in d[]