Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
New Contributor I
1,175 Views

Problems with Intel Edison(SPI, PWM and Timer)

Hi guys,

I have been trying to interface the http://www.ti.com/tool/430BOOST-SHARP96 Sharp Memory LCD booster pack lately with edison and encounterd a number of problems. I will list them out in the order which they occured.

(Note: I am using Intel edison with the arduino expansion board and mraa libraries to code in C)

1. First of all the data for the LCD must be in MSB(little-endian) format. The mraa_spi_lsbmode(spi, 0) doesn't seem to work.

2. The VCOM bit of the LCD must be toggled at a minimum of 1 Hz to prevent charge build-up. This can be done either by software or hardware. I tried both which ended up in different problems:

a) Software mode: The timer(kernel) was set to interrupt for every second so that the VCOM bit could be updated through the SPI bus. This didn't go well as the interrupt handler messes up with the current SPI Transmission.

b) Hardware mode: The EXTCOMIN pin must be toggled at a minimum of 1 Hz. I tried generating a PWM for 1Hz but in vain. The PWM's lowest possible frequency was 20Hz. I used https://github.com/intel-iot-devkit/mraa/blob/master/examples/cycle-pwm3.c this as an example.

So either way its impossible to toggle the VCOM bit.

If any of you guys had some experience with the SHARP Memory Display please make some suggestions. I have been struggling for the past week with no positive results. I am attaching my Source code in the post.

Thanks in advance and Cheers

Additional links:

http://www.sharpmemorylcd.com/resources/ls013b4dn04_application_info.pdf SHARP Memory LCD Datasheet

http://www.sharpmemorylcd.com/resources/Programming_Memory_LCD_App_Note.pdf SHARP Display Programming Guide

http://www.teuniz.net/Timer_code/ Timer Code which is used for Interrupt

0 Kudos
10 Replies
Highlighted
Employee

Re: Problems with Intel Edison(SPI, PWM and Timer)

Hello freddy7phil,

Unfortunately I don't have a http://www.ti.com/tool/430BOOST-SHARP96 Sharp ® Memory LCD BoosterPack - 430BOOST-SHARP96 - TI Tool Folder so I won't be able to test it, but regarding your issues with the PWM frequency, according to http://www.intel.com/support/edison/sb/CS-035274.htm Intel® Edison Compute Module Hardware Guide in section 4.8 it says that Edison's PWM has operating frequencies from 0 to 9.6MHz, so this might be an issue with MRAA, which version of the library is installed on your board? Which image is on your board?

Nevertheless, a frequency of 1Hz it's something a regular GPIO can do, why don't you try using one for the VCOM toggling?

 

Peter.

Highlighted
New Contributor I

Re: Problems with Intel Edison(SPI, PWM and Timer)

Hi Peter,

Ya I have already tried toggling the GPIO pin usng a timer Interrupt for 1Hz but it messes up with my SPI communication. The code which I had attached contains the GPIO toggling of the VCOM bit.

Today I bumped into a new problem with the eclipse IDE. So far I have been Programming and Compiling through the edison kernel. Today I tried the Eclipse IDE but could not even create a new project.

I have started a new discussion for that:

Highlighted
Employee

Re: Problems with Intel Edison(SPI, PWM and Timer)

Hi freddy7phil,

I will try to test the PWM frequencies with MRAA, but I'll try to do it on your same circumstances, what image are you using and which version of MRAA do you have installed?

Peter.

0 Kudos
Highlighted
New Contributor I

Re: Problems with Intel Edison(SPI, PWM and Timer)

Hi Peter,

My setup:

PC- Windows 8.1(64-bit)

Image(latest) and IDE: Eclipse IOT Edition(Installed through the latest Integrated Installer)

JRE - 8 Update 40(64-bit)

MRAA Version: v0.6.1

I use the following code:

/*

* PWM_C_Test.c

*

* Created on: 06.03.2015

* Author: Frederic P.

*/

# include

# include "mraa.h"

# define TIME_PERIOD 1 //Time Period in Hz

# define DUTY_CYCLE 0.5f //Duty Cycle(0.0f - 1.0f)

int main ()

{

mraa_init();

mraa_pwm_context pwm;

pwm = mraa_pwm_init(3);

if (pwm == NULL)

{

return 1;

printf("PWM Initialization Failed");

}

mraa_pwm_period(pwm, TIME_PERIOD);

mraa_pwm_enable(pwm, 1);

mraa_pwm_write(pwm, DUTY_CYCLE);

float output = mraa_pwm_read(pwm);

return 0;

}

}

The use of the other PWM functions namely: mraa_pwm_period_ms() and mraa_pwm_period_us() has absolutely no effect. I get a constant frequency of 196.8 Hz(Changing the period value has no effect whatsoever)

Additional notes:

I use the Arduino expansion board for testing. The swizzler jumpers are in the factory default. The IOREF is set to 3.3V.

Please ask me if u require any additional information. Waiting for your reply.

Thanks in advance.

P.S.

What is the diff. bw mraa_pwm_period() and mraa_pwm_pulsewidth()?

0 Kudos
Highlighted
New Contributor I

Re: Problems with Intel Edison(SPI, PWM and Timer)

Hi Peter,

I made a few changes to the code. I set the Pin 3(pwm0) as output and enabled it into one as mentioned in the following posts: Intel_Jesus, AlexanderMerz, rwaldron, Intel_Alvarado, KurtE, CMata_Intel could help me out.

Thanks in advance

0 Kudos
Highlighted
Valued Contributor III

Re: Problems with Intel Edison(SPI, PWM and Timer)

Sorry I am not really any help in this... The only things I can tell you is what I see in the MRAA code base. Things like:

TIME_PERIOD - Your usage here is in period in ms not in Hz... (probably just a comment issue above)

From the MRAA sources for the Edison board we have:

pwm_max_period = 218453;

pwm_min_period = 1;

These values are in us. So yes the max value you can pass into mraa_pwm_period_ms is 218, which when you take 1000/218 gives you 4.587155963302752. HZ

Now again these defines are in the mraa sources. I could not tell you if these are actual limits to the underlying hardware or not.

Kurt

0 Kudos
Highlighted
New Contributor I

Re: Problems with Intel Edison(SPI, PWM and Timer)

Hi KurtE and Peter,

Thanks for the insight. I am guessing that you found the pwm_max_period & pwm_min_period here: https://github.com/intel-iot-devkit/mraa/blob/73751462953b9bf36e0dba6403841dee77542270/src/x86/intel... L716 mraa/intel_edison_fab_c.c at 73751462953b9bf36e0dba6403841dee77542270 · intel-iot-devkit/mraa · GitHub

Here is a snippet from https://github.com/intel-iot-devkit/mraa/tree/73751462953b9bf36e0dba6403841dee77542270 mraa/https://github.com/intel-iot-devkit/mraa/tree/73751462953b9bf36e0dba6403841dee77542270/src src/https://github.com/intel-iot-devkit/mraa/tree/73751462953b9bf36e0dba6403841dee77542270/src/x86 x86/intel_edison_fab_c.c :

I investigated the MRAA code-base and found this section of code here: https://github.com/intel-iot-devkit/mraa/blob/41956b07d65bfaed7e872632a67af385f5fbacc4/src/pwm/pwm.c mraa/pwm.c at 41956b07d65bfaed7e872632a67af385f5fbacc4 · intel-iot-devkit/mraa · GitHub

Code Snippet from https://github.com/intel-iot-devkit/mraa/tree/41956b07d65bfaed7e872632a67af385f5fbacc4 mraa/https://github.com/intel-iot-devkit/mraa/tree/41956b07d65bfaed7e872632a67af385f5fbacc4/src src/https://github.com/intel-iot-devkit/mraa/tree/41956b07d65bfaed7e872632a67af385f5fbacc4/src/pwm pwm/pwm.c :

So as I see from the code, setting a period value of more than 218453 must produce a SYSLOG error, which in this case is not being produced.

I have a question based on this: Can the pwm_max_value manually set to a higher value to produce the desired frequency? Are there any safety reasons for using the limiting value?

I also found the following table from section 4.8 - PWM of the Intel Edison Compute Module http://download.intel.com/support/edison/sb/edisonmodule_hg_331189004.pdf http://download.intel.com/support/edison/sb/edisonmodule_hg_331189004.pdf

It says that a frequency between 0 - 9.6 Mhz can be set. I am aiming for a 1 Hz signal. The example value shows the limiting frequency of 4.6 Hz. What does this signify?

Thanks in advance

0 Kudos
Highlighted
New Contributor I

Re: Problems with Intel Edison(SPI, PWM and Timer)

Hi Intel_Peter

Have you tested the PWM signal? Waiting for your response...

0 Kudos
Highlighted
Employee

Re: Problems with Intel Edison(SPI, PWM and Timer)

Hello Frederic Philips,

I've been testing PWM on Edison and found out, as you said, one cannot set the PWM frequencies lower than 4.6Hz, I found that weird, so I wrote my own code, nevertheless nothing changed, so I tried a different approach, I tried to set it up on Linux, and that's when I found out that the period is limited to a maximum of 218453000ns, and that's the reason why the frequency can't be set lower than 4,6Hz. The only solution I can think of right now, as I said before would be to use a regular GPIO.

Peter.

0 Kudos
Highlighted
New Contributor I

Re: Problems with Intel Edison(SPI, PWM and Timer)

Hi Peter,

Thanks for the info. I also bumped into the same range error when I tried to echo the period setting through the following script:

# !/bin/sh

echo 254 > /sys/class/gpio/export

echo 222 > /sys/class/gpio/export

echo 214 > /sys/class/gpio/export

echo low > /sys/class/gpio/gpio214/direction

 

echo high > /sys/class/gpio/gpio254/direction

 

echo in > /sys/class/gpio/gpio222/direction

 

echo mode1 > /sys/kernel/debug/gpio_debug/gpio182/current_pinmux

 

echo high > /sys/class/gpio/gpio214/direction

 

echo 2 > /sys/class/pwm/pwmchip0/export

 

echo 1000000000 > /sys/class/pwm/pwmchip0/pwm2/period

 

echo 500000000 > /sys/class/pwm/pwmchip0/pwm2/duty_cycle

 

echo 1 > /sys/class/pwm/pwmchip0/pwm2/enable

Console error:

sh: write error: Device or resource busy[ 7737.287462] pwm-intel-mid 0000:00:17.0: Period (ns) must be in range 104:218453000

So, anomalous PWM behaviour solved. But still struggling with the SPI:

0 Kudos