LCD interfacing with ARM cortex M0+ lpc845 - c

I'm trying to interface 8x2 lcd using parallel interfacing[4 bit mode],
Display used - 8x2 lcd [PC 0802--A]
ST7066U--Dot Matrix LCD Controller/Driver
Since i'm trying to interface using GPIO pins, not using I2C or SPI
interface, and since no drivers are there for this particular MCU[LPC845],
I compared with lpc2148 MCU [lcd.c and lcd.h files], and have made the changes, but not able to write to the display.
And when checked the data/command signals in the oscilloscope, in data pins
I'm getting float voltages[i.e., for d4-D7] LOW signal on this pins, and
high signals on command pins[RS,RW,EN].
Kindly suggest me the process of writing the char/string to the display varies for ARM mcu?as i'm referring lpc2148 libraries.
Thank you

Related

How to get data from pins other than the control signals pins?

I have a GPS module, it has control signals pins such as RX and TX, however, it has also two other pins named 3D fix and 1PP (1 pulse per second). How can I get data from those two pins without using Arduino?
I'm using termios and unistd unix libraries to do serial programming. I'm also using usbuart converter between the GPS module and my laptop.

Read non conventional ADC with STM32F3

I'm attempting to interface an STM32F303 Nucleo with an AD7748-4 ADC. Datasheet for the ADC:
https://www.analog.com/media/en/technical-documentation/data-sheets/ad7768-7768-4.pdf
The issue is, the ADC DOES NOT output the converted value through the SPI port, but rather employs a Data Ready Signal (DRDY), a Data Clock (DCLK), and a combination of 4 Data Outputs (DOUT0-DOUT3). The output streams 96 bits serially through one wire if I set it up that way, but timing is critical in my application and I need to clock the data in using DOUT0 to DOUT2, which would each output 32 bits. If I were serially streaming the data, I could trick the SPI port into reading it, but I'm not. The ADC is running at 20MHz, so DCLK will be operating at the same frequency. The Nucleo runs at a maximum of 72MHz, but when the DAM is utilized, it sets the clock to 64MHz.
In the STM manual, it describes a "GPIO port input data register (GPIOx_IDR) (x = A..H)" as being a read only register - my understanding is that the lower 16 bits can store an inputted value up to 16 bits (most likely for memory data R/W) - so the question is, how can I configure the GPIO to read in the data? I'm at a slight impass here. My instinct tells me that the Nucleo may not be fast enough to read the data coming from the ADC... Any ideas? All being written in C/C++ basically bare metal... I'm new to the Nucleo, haven't written code in 4 years - pardon any lapse in knowledge...
If DCLK works at 20Mhz, the uC is obviously not fast enough (you have about 3 instructions between each cycle, so even assembly language would be difficult to implement...). As I am not familiar with the stm architecture, I can only suggest a trick that will maybe spark some ideas in your head. Rather than using a crystal for the ADC, use a timer from the STM that is connected to an output pin, and clock the ADC using that pin (MCLK). When configuring the ADC using spi, idle mode, etc. you can leave this clock signal at 20Mhz. But when you need a sample from the ADC, stop the STM timer and clock the ADC "manually". (you practically control the DCLK signal). After your conversion routine is over, restart the timer at 20Mhz.

How to blink LED after every 1 second using timers in LPC 1768 (C Programming)?

I am new in micro controller programming .I am using embedded C platform for coding. I want to blink LED after every 1 second using timers in LPC 1768. I have option of generating delay using empty "for" loops and crystal frequency for calculation of counter value. But this delay is not precise.
In the given board LPC 1768 is connected to the LEDs through PCA 9532 I2c bus. For controlling LEDs I should use SDA and SCL pins of PCA 9532 .I want to make use of LPC 1768 timers for generating delay of 1 second so that I could blink the LED with 1 second time interval.But problem is that LPC1768 is not directly connected to LED . PCA 9532 is in between them. So can anybody tell me how can I perform it?
It seems like you have to talk to the PCA9532 via I2C.
configure the LPC pins to use I2C
write a simple driver which writes commands over I2C.
configure the PCA9532 via these commands.
PS: If you don't want to write real I2C drivers, you could bit-bang the commands. Be sure to reconfigure the GPIO (SDA) as input to read ACK from chip.
PPS: you find the command structure in the linked datasheet in chapter 7.1 and a sample communication in chapter 8.2.
Hope that's a first help.

Interfacing the GPS module with MSP430

I already interfacing the GPS s-1216 module with 8051. Now I'm going to interfacing the same module with MSP430fr5969 launchpad. I facing the problem in starting itself that to which pin is connection will be doing? can anyone will solve this.. If it possible explain using code functions..
You can use any of this. Either 0 or 1.
PIN 20-TX1, PIN 21-RX1; PIN 24-TX0, PIN 25-RX0.
Select the appropriate function using selection register as each pin has more than 2 functions. In 8051 there is nothing called selection register. But here it is used to define the function of PIN.
Rest of the things are same as in 8051, like UART configuration, baud rate and TX RX functions.
Before trying UART, try blinky IO program to get the basic knowledge on MSP430

Steps to make a LED on or off from a C program using Serial Port?

I knew there is a similar post:
Steps to make a LED blink from a C/C++ program?
But now I am working on a arm-based development board, and it seems to have two serial ports that I could use it to make a LED on or off.
Basically I think the flow is , make one pin in serial "1" or on and the LED will be turned on and "0" to make it off.
Is there some reference code in C-language I could refers?
Generally speaking, the board should come with some Board Support Package (BSP) which lets you control the built in I/O. Look for a serial library if you really want to use the Hardware flow control signals.
I'd recommend looking for some GPIO (General Purpose I/O, or digial I/O) on the board, which typically lets you configure it as an input or an output. You should be able to connect the LED via a current limiting resister between a digital I/O line and a ground pin. Make sure you have the LED oriented correctly if you connect it backwards it will block the current instead lighting. And as always make sure you check it out with a digital voltage meter before connecting it.
Even if you don't have a BSP for digital I/O the configuration is usually pretty simple.
Set a bit in a register to enable it, set bit in another register to select input or output they will normally be arranged in 8-bit "ports." Some systems allow you configure individual I/O pins, other will only allow you to configure the whole port for input or output. Then you just write a 1 or 0 to the bit you want to control in an write/output register.
ARM chips typically have a considerable amount of built in peripherals today, so most boards will just be bringing the I/O out to physical connectors on the board and you may need to read the chip vender's documentation to find the register memory map. Better board venders will supply documentation, a library (BSP) and examples. Luminary Micro even supplies chips with built in ethernet MACs and PHYs, just add a connector and Magnetics and you have a 1 chip Webserver.
This will, I'm afraid, be heavily dependent on the specifications of the particular arm-based development board you are using.
You need to find documentation specific to that board.
I used to do this kind of programming before.
You need to study the serial port connection
http://www.lammertbies.nl/comm/cable/RS-232.html
http://www.beyondlogic.org/serial/serial.htm
It has +5v, -5v on the output, I can't remember clearly now. Not every pin is needed.
I never use ARM before, but I use a 8-bit PIC controller to program it. I guess you can find a lot of example online.
The preferred alternative for controlling a GPIO is via a BSP. Because this BSP (board support package) does all the work for you in setting all peripherals to good defaults and and allowing you to call a function. Possibly your BSP of choice will have a function to write a byte to an 8-bit GPIO port; your LED will only have one bit. In this case your C code could look like: (at least: it will work like this on Luminary Micro kits). (Example code; requires a bit of extra work to make it compile especially on your kit).
/* each LED is addressed by an address (byte) and a bit-within-this-byte */
struct {
address, // address of IO register for LED port
bit // bit of LED
} LEDConfigPair;
struct LEDConfigPair LEDConfig[NUMBER_OF_LEDS] = {
{GPIO_PORTB_BASE,0}, // LED_0 is at port B0
{GPIO_PORTB_BASE,1} // LED_1 is at port B1
} ;
/* function LED_init configures the GPIOs where LEDs are connected as output */
led_init(void)
{
U32 i;
for(i=0;i<NUMBER_OF_LEDS;i++)
{
GPIODirModeSet( LEDConfig[i][0], LEDConfig[i][1], GPIO_DIR_MODE_OUT );
}
}
/* my LED function
set_led_state makes use of the BSP of Luminary Micro to access a GPIO function
Implementation: this BSP requires setting 8 port wide IO, so the function will calculate a mask (
*/
set_led_state(U8 led,bool state)
{
U8 andmask;
U8 setmask;
andmask = ~(1 << LEDConfig[led].bit);// a bitmask with all 1's except bit of LED
if (true == state)
{
setmask = (1 << LEDConfig[led].bit); // set bit for LED
} else
{
setmask = 0;
}
GPIOPinWrite(LEDConfig[led].address, andmask, setmask);
}
Of course this is all spelled out; it can be done in a single lines like this:
#DEFINE SETLEDSTATE(led,state) GPIOPinWrite(LEDConfig[led].address, ~(1<<LEDConfig[led].bit),(state<<LEDConfig[led].bit))
this will do the same, but only makes sense when you can dream bit masks, and you only want to toggle some LEDs to debug the real program...
The alternative: bare metal.
In this case you need to set up everything for yourself. For an embedded system, you need to be aware of pin multiplexing and power management (assuming memory controller and cpu clocks are already set up!)
initialization: set pin multiplexing in such a way that the function you want to control is actually mapped on the package.
initialization of pheripheral (in this case either a UART, or a GPIO function on the same pin)
You can't do it using Rx or Tx pins of Serial port. For that you just need to control the RTS or CTS pins of serial port.
Just google for "access COM port in VC++ code" and then control the RTS and CTS status pins to turn ON and OFF any external device.

Resources